Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions default.nix

This file was deleted.

189 changes: 189 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

155 changes: 155 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
description = "Flake for acm-aws";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=50aa30a13c4ab5e7ba282da460a3e3d44e9d0eb3";

flake-utils.url = "github:numtide/flake-utils";

gomod2nix.url = "github:nix-community/gomod2nix";
gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
gomod2nix.inputs.flake-utils.follows = "flake-utils";

poetry2nix.url = "github:nix-community/poetry2nix";
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
poetry2nix.inputs.flake-utils.follows = "flake-utils";

nix-npm-buildpackage.url = "github:serokell/nix-npm-buildpackage";
nix-npm-buildpackage.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = {
self,
nixpkgs,
flake-utils,
gomod2nix,
poetry2nix,
nix-npm-buildpackage,
}@inputs:

flake-utils.lib.eachDefaultSystem (system:
let
overlays = self.overlays.${system};
in
{
devShells = let
pkgs = import nixpkgs {
inherit system;
overlays = [
overlays.buildTools
];
config = {
# Allow unfree packages for Terraform.
allowUnfree = true;
};
};
in
{
default = pkgs.mkShell {
name = "acm-aws-shell";

packages = with pkgs; [
terraform
awscli2
nix-update
jq
niv
git
git-crypt
openssl
yamllint
expect
shellcheck
] ++ [
# Fix Nix Flake's weird scoping issue.
pkgs.gomod2nix
];

# Enforce purity by unsetting NIX_PATH.
# This messes up any code that uses Nix channels.
NIX_PATH = "";
};
};

overlays = {
# Overlay for the build tools that our packages use.
buildTools = final: prev: {
#
# Build tools
#
inherit (gomod2nix.legacyPackages.${system})
mkGoEnv buildGoApplication gomod2nix;

inherit (poetry2nix.lib.mkPoetry2Nix { pkgs = prev; })
mkPoetryApplication;

inherit (nix-npm-buildpackage.legacyPackages.${system})
buildNpmPackage
buildYarnPackage;

buildDenoPackage = final.callPackage ./nix/packaging/deno.nix { };
buildJavaPackage = final.callPackage ./nix/packaging/java.nix { };
buildGradlePackage = final.callPackage ./nix/packaging/gradle.nix { };
buildPoetryPackage = final.callPackage ./nix/packaging/poetry.nix { };

#
# Miscellanous tools
#
nix-update = final.callPackage ./nix/nix-update.nix { };

#
# Miscellanous utility derivations
#
pkgutil = final.callPackage ./nix/pkgutil.nix { };
sources = import ./nix/sources.nix {
inherit system;
pkgs = prev;
};
};
# Overlay adding our own packages.
default = final: prev: self.packages.${system};
};

packages = import ./packages {
pkgs = nixpkgs.legacyPackages.${system}.extend (overlays.buildTools);
};

nixosConfigurations = {
cirno = self.lib.nixosSystem {
system = "x86_64-linux";
configuration = ./servers/cirno/configuration.nix;
};
cs306 = self.lib.nixosSystem {
system = "x86_64-linux";
configuration = ./servers/cs306/configuration.nix;
};
};

lib = {
# All nixosConfigurations should have this in their specialArgs.
nixosArgs = { system }: inputs // {
# Import Niv sources directly into the arguments for convenience.
sources = import ./nix/sources.nix {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
};
# TODO: migrate away from Nix store-based secrets.
# See https://github.com/acmcsufoss/acm-aws/issues/34.
secretsPath = secret: self + "/secrets/" + secret;
};

mkNixosSystem = { system, configurationFile }:
nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./servers/base.nix
configurationFile
];
specialArgs = self.lib.nixosArgs {
inherit system;
};
};
};
}
);
}
8 changes: 2 additions & 6 deletions nix/packaging/poetry.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{ poetry2nix, writeShellScriptBin, python3 }:

let
pkgutil = import <acm-aws/nix/pkgutil.nix>;
in
{ pkgutil, mkPoetryApplication, writeShellScriptBin, python3 }:

{
name ? "${pname}-${version}",
Expand All @@ -16,7 +12,7 @@ in
}:

let
poetryApplication = (poetry2nix.mkPoetryApplication {
poetryApplication = (mkPoetryApplication {
inherit src python;
pyproject = "${src}/pyproject.toml";
poetrylock = "${src}/poetry.lock";
Expand Down
2 changes: 2 additions & 0 deletions nix/pkgutil.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{ pkgs }:

{
version = src:
if (src ? version && src.version != "")
Expand Down
Loading