From 73b04cd8498fdf23d3c9e65602f1cb9b5d7733be Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 7 Sep 2024 12:01:28 -0400 Subject: .envrc: watch dev/dev-shells.nix --- .envrc | 1 + dev/README.md | 4 ++-- dev/default.nix | 4 ++-- dev/dev-shells.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ dev/devShells.nix | 42 ------------------------------------------ dev/hydra-jobs.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dev/hydraJobs.nix | 50 -------------------------------------------------- 7 files changed, 97 insertions(+), 96 deletions(-) create mode 100644 dev/dev-shells.nix delete mode 100644 dev/devShells.nix create mode 100644 dev/hydra-jobs.nix delete mode 100644 dev/hydraJobs.nix diff --git a/.envrc b/.envrc index 8adac03..1ed50d3 100644 --- a/.envrc +++ b/.envrc @@ -1,4 +1,5 @@ if has nix_direnv_version; then + watch_file dev/dev-shells.nix use flake fi diff --git a/dev/README.md b/dev/README.md index ac255bc..58d8360 100644 --- a/dev/README.md +++ b/dev/README.md @@ -1,10 +1,10 @@ # ./dev/ -## devShells.nix +## dev-shells.nix A misnomer - this only contains one shell -## hydraJobs.nix +## hydra-jobs.nix Jobs I want to run in CI. Currently built by [`nix-fast-build`](https://github.com/Mic92/nix-fast-build) diff --git a/dev/default.nix b/dev/default.nix index d1a371e..e74789e 100644 --- a/dev/default.nix +++ b/dev/default.nix @@ -1,7 +1,7 @@ { imports = [ - ./devShells.nix - ./hydraJobs.nix + ./dev-shells.nix + ./hydra-jobs.nix ./treefmt.nix ]; } diff --git a/dev/dev-shells.nix b/dev/dev-shells.nix new file mode 100644 index 0000000..211ddfd --- /dev/null +++ b/dev/dev-shells.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 + + # format + lint + pkgs.actionlint + self'.formatter + pkgs.nixfmt-rfc-style + pkgs.nil + pkgs.statix + + # utils + pkgs.fzf # for just + pkgs.just + + # terranix + self'.packages.opentofu + ] + # see above comment about nix + ++ lib.optional pkgs.stdenv.isDarwin inputs'.nix-darwin.packages.darwin-rebuild + ++ lib.optionals pkgs.stdenv.isLinux [ + pkgs.nixos-rebuild # ditto + inputs'.agenix.packages.agenix + ]; + }; + }; + }; +} diff --git a/dev/devShells.nix b/dev/devShells.nix deleted file mode 100644 index 211ddfd..0000000 --- a/dev/devShells.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - 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 - - # format + lint - pkgs.actionlint - self'.formatter - pkgs.nixfmt-rfc-style - pkgs.nil - pkgs.statix - - # utils - pkgs.fzf # for just - pkgs.just - - # terranix - self'.packages.opentofu - ] - # see above comment about nix - ++ lib.optional pkgs.stdenv.isDarwin inputs'.nix-darwin.packages.darwin-rebuild - ++ lib.optionals pkgs.stdenv.isLinux [ - pkgs.nixos-rebuild # ditto - inputs'.agenix.packages.agenix - ]; - }; - }; - }; -} diff --git a/dev/hydra-jobs.nix b/dev/hydra-jobs.nix new file mode 100644 index 0000000..7b55f57 --- /dev/null +++ b/dev/hydra-jobs.nix @@ -0,0 +1,50 @@ +{ + lib, + self, + withSystem, + ... +}: +let + # architecture of "main" CI machine + ciSystem = "x86_64-linux"; + + /** + Map a NixOS, nix-darwin, or home-manager configuration to a final derivation + + # Type + + ``` + derivFromCfg :: AttrSet -> Attrset + ``` + */ + derivFromCfg = deriv: deriv.config.system.build.toplevel or deriv.activationPackage; + + /** + Map an attribute set of NixOS, nix-darwin, or home-manager configurations to their final derivation + + # Type + + ``` + mapCfgsToDerivs :: AttrSet -> Attrset + ``` + */ + mapCfgsToDerivs = lib.mapAttrs (lib.const derivFromCfg); +in +{ + flake.hydraJobs = 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; + inherit (self') 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/dev/hydraJobs.nix b/dev/hydraJobs.nix deleted file mode 100644 index 7b55f57..0000000 --- a/dev/hydraJobs.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ - lib, - self, - withSystem, - ... -}: -let - # architecture of "main" CI machine - ciSystem = "x86_64-linux"; - - /** - Map a NixOS, nix-darwin, or home-manager configuration to a final derivation - - # Type - - ``` - derivFromCfg :: AttrSet -> Attrset - ``` - */ - derivFromCfg = deriv: deriv.config.system.build.toplevel or deriv.activationPackage; - - /** - Map an attribute set of NixOS, nix-darwin, or home-manager configurations to their final derivation - - # Type - - ``` - mapCfgsToDerivs :: AttrSet -> Attrset - ``` - */ - mapCfgsToDerivs = lib.mapAttrs (lib.const derivFromCfg); -in -{ - flake.hydraJobs = 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; - inherit (self') 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; - }; - } - ); -} -- cgit v1.2.3