diff options
| author | seth <[email protected]> | 2025-01-05 23:24:04 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-01-06 04:24:04 +0000 |
| commit | a0726ea66d1857eb2e1c9d7dfd2f10d30ac64706 (patch) | |
| tree | 585d4c7706ef52fc037419958b0af86e216a5d43 /flake | |
| parent | 85e702efc03b04cbb0ac5b1b2ef79c21602c8ed8 (diff) | |
treewide: back to flake parts (#539)
* treewide: back to flake parts
* treewide: drop extra docs
these are kind pointless
Diffstat (limited to 'flake')
| -rw-r--r-- | flake/ci.nix | 72 | ||||
| -rw-r--r-- | flake/default.nix | 13 | ||||
| -rw-r--r-- | flake/dev-shell.nix | 42 |
3 files changed, 127 insertions, 0 deletions
diff --git a/flake/ci.nix b/flake/ci.nix new file mode 100644 index 0000000..cd1857f --- /dev/null +++ b/flake/ci.nix @@ -0,0 +1,72 @@ +{ + lib, + withSystem, + self, + ... +}: + +{ + perSystem = + { pkgs, ... }: + { + quickChecks = { + actionlint = { + dependencies = [ pkgs.actionlint ]; + script = "actionlint ${self}/.github/workflows/**"; + }; + + deadnix = { + dependencies = [ pkgs.deadnix ]; + script = "deadnix --fail ${self}"; + }; + + just = { + dependencies = [ pkgs.just ]; + script = '' + cd ${self} + just --check --fmt --unstable + just --summary + ''; + }; + + nixfmt = { + dependencies = [ pkgs.nixfmt-rfc-style ]; + script = "nixfmt --check ${self}/**/*.nix"; + }; + + statix = { + dependencies = [ pkgs.statix ]; + script = "statix check ${self}"; + }; + }; + }; + + flake = { + hydraJobs = + + let + # Architecture of "main" CI machine + ciSystem = "x86_64-linux"; + + derivFromCfg = deriv: deriv.config.system.build.toplevel or deriv.activationPackage; + mapCfgsToDerivs = lib.mapAttrs (lib.const derivFromCfg); + in + + withSystem ciSystem ( + { pkgs, self', ... }: + + { + # I don't care to run these for each system, as they should be the same + # and don't need to be cached + inherit (self') checks devShells; + + darwinConfigurations = mapCfgsToDerivs self.darwinConfigurations; + homeConfigurations = mapCfgsToDerivs self.homeConfigurations; + nixosConfigurations = mapCfgsToDerivs self.nixosConfigurations // { + # please add aarch64 runners github...please... + atlas = lib.deepSeq (derivFromCfg self.nixosConfigurations.atlas).drvPath pkgs.emptyFile; + }; + } + ); + }; +} diff --git a/flake/default.nix b/flake/default.nix new file mode 100644 index 0000000..ba160ff --- /dev/null +++ b/flake/default.nix @@ -0,0 +1,13 @@ +{ + imports = [ + ./ci.nix + ./dev-shell.nix + ]; + + perSystem = + { pkgs, ... }: + + { + formatter = pkgs.nixfmt-rfc-style; + }; +} diff --git a/flake/dev-shell.nix b/flake/dev-shell.nix new file mode 100644 index 0000000..46e6ed0 --- /dev/null +++ b/flake/dev-shell.nix @@ -0,0 +1,42 @@ +{ + perSystem = + { + lib, + pkgs, + inputs', + self', + ... + }: + + { + devShells.default = pkgs.mkShellNoCC { + packages = + [ + # We want to make sure we have the same + # Nix behavior across machines + pkgs.nix + + # For CI + pkgs.actionlint + + # Nix tools + pkgs.nil + pkgs.statix + self'.formatter + + pkgs.just + ] + ++ lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ + # See above comment about Nix + inputs'.nix-darwin.packages.darwin-rebuild + ] + ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ + + # Ditto + pkgs.nixos-rebuild + + inputs'.agenix.packages.agenix + ]; + }; + }; +} |
