diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index ee97846..89693ab 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -8,4 +8,4 @@ jobs: runs-on: native steps: - uses: actions/checkout@v4 - - run: nix-build -A ci.check + - run: nix flake check --all-systems diff --git a/default.nix b/default.nix deleted file mode 100644 index bb13b3b..0000000 --- a/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -let - nilla = import ./nilla.nix { }; - getPackage = name: nilla.packages.${name}.result.${builtins.currentSystem}; -in -{ - ci.check = getPackage "ci-check"; - formatter = getPackage "formatter"; -} diff --git a/hosts/default.nix b/hosts/default.nix index 843a8d1..3c8b713 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -16,7 +16,7 @@ in ./youko ]; - config.systems.builders = + config.configBuilders = let sharedOptions = { _file = ./default.nix; diff --git a/hosts/hijiri-vm/default.nix b/hosts/hijiri-vm/default.nix index 94350be..5f6d088 100644 --- a/hosts/hijiri-vm/default.nix +++ b/hosts/hijiri-vm/default.nix @@ -1,5 +1,5 @@ { - config.systems.nixos.hijiri-vm.module = + config.configurations.nixos.hijiri-vm = { modulesPath, lib, diff --git a/hosts/hijiri/default.nix b/hosts/hijiri/default.nix index 66defb4..a0e6857 100644 --- a/hosts/hijiri/default.nix +++ b/hosts/hijiri/default.nix @@ -1,5 +1,5 @@ { - config.systems.darwin.hijiri.module = + config.configurations.darwin.hijiri = { config, pkgs, diff --git a/hosts/kazuki/default.nix b/hosts/kazuki/default.nix index d0fad10..029d7d0 100644 --- a/hosts/kazuki/default.nix +++ b/hosts/kazuki/default.nix @@ -1,5 +1,5 @@ { - config.systems.nixos.kazuki.module = + config.configurations.nixos.kazuki = { modulesPath, ... diff --git a/hosts/kogata/default.nix b/hosts/kogata/default.nix index d5ac7cb..3e7c21f 100644 --- a/hosts/kogata/default.nix +++ b/hosts/kogata/default.nix @@ -1,5 +1,5 @@ { - config.systems.darwin.kogata.module = + config.configurations.darwin.kogata = { pkgs, ... }: { nixpkgs.system = "aarch64-darwin"; diff --git a/hosts/ude/default.nix b/hosts/ude/default.nix index 62ffb2e..fd3e19b 100644 --- a/hosts/ude/default.nix +++ b/hosts/ude/default.nix @@ -1,5 +1,5 @@ { - config.systems.nixos.ude.module = + config.configurations.nixos.ude = { config, modulesPath, diff --git a/hosts/youko/default.nix b/hosts/youko/default.nix index 7f39ac5..b801507 100644 --- a/hosts/youko/default.nix +++ b/hosts/youko/default.nix @@ -1,5 +1,5 @@ { - config.systems.nixos.youko.module = + config.configurations.nixos.youko = { config, lib, diff --git a/modules/nilla/configurations.nix b/modules/nilla/configurations.nix new file mode 100644 index 0000000..6f02f7e --- /dev/null +++ b/modules/nilla/configurations.nix @@ -0,0 +1,47 @@ +{ config, lib }: +{ + options = { + configBuilders = { + nixos = lib.options.create { + type = lib.types.function lib.types.raw; + default.value = _name: config.inputs.nixpkgs.result.lib.nixosSystem; + }; + darwin = lib.options.create { + type = lib.types.function lib.types.raw; + default.value = _name: config.inputs.darwin.result.lib.darwinSystem; + }; + home = lib.options.create { + type = lib.types.function lib.types.raw; + default.value = _name: config.inputs.home-manager.result.lib.homeManagerConfiguration; + }; + }; + + configurations = { + nixos = lib.options.create { + type = lib.types.attrs.lazy lib.types.raw; + default.value = { }; + }; + darwin = lib.options.create { + type = lib.types.attrs.lazy lib.types.raw; + default.value = { }; + }; + home = lib.options.create { + type = lib.types.attrs.lazy lib.types.raw; + default.value = { }; + }; + }; + + nixosConfigurations = lib.options.create { + type = lib.types.attrs.lazy lib.types.raw; + default.value = builtins.mapAttrs config.configBuilders.nixos config.configurations.nixos; + }; + darwinConfigurations = lib.options.create { + type = lib.types.attrs.lazy lib.types.raw; + default.value = builtins.mapAttrs config.configBuilders.darwin config.configurations.darwin; + }; + homeConfigurations = lib.options.create { + type = lib.types.attrs.lazy lib.types.raw; + default.value = builtins.mapAttrs config.configBuilders.home config.configurations.home; + }; + }; +} diff --git a/modules/nilla/default.nix b/modules/nilla/default.nix index 0cab965..71aed0d 100644 --- a/modules/nilla/default.nix +++ b/modules/nilla/default.nix @@ -2,7 +2,7 @@ includes = [ ./builders ./services.nix - ./systems.nix + ./configurations.nix ./modules.nix ./flake.nix ]; diff --git a/modules/nilla/flake.nix b/modules/nilla/flake.nix index 0193f2d..f3fe6f1 100644 --- a/modules/nilla/flake.nix +++ b/modules/nilla/flake.nix @@ -18,12 +18,11 @@ in nixosModules darwinModules homeModules + nixosConfigurations + darwinConfigurations + homeConfigurations ; - nixosConfigurations = builtins.mapAttrs (_: system: system.result) config.systems.nixos; - darwinConfigurations = builtins.mapAttrs (_: system: system.result) config.systems.darwin; - homeConfigurations = builtins.mapAttrs (_: system: system.result) config.systems.home; - devShells = transpose config.shells; packages = transpose config.packages; diff --git a/modules/nilla/systems.nix b/modules/nilla/systems.nix deleted file mode 100644 index 63b349a..0000000 --- a/modules/nilla/systems.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ config, lib }: -let - mkBuilderOption = - typ: - lib.options.create { - type = lib.types.function (lib.types.function lib.types.raw); - default.value = _name: _module: throw "Builder for systems.${typ} is not implemented"; - }; - inherit (config.systems) builders; - mkSystemModule = - typ: - { config, name }: - { - options = { - name = lib.options.create { - type = lib.types.string; - default.value = name; - }; - module = lib.options.create { - type = lib.types.raw; - default.value = { }; - }; - builder = lib.options.create { - type = lib.types.function (lib.types.function lib.types.raw); - default.value = builders.${typ}; - }; - result = lib.options.create { - type = lib.types.raw; - writable = false; - default.value = config.builder config.name config.module; - }; - }; - }; - mkSystemOption = - typ: - lib.options.create { - type = lib.types.attrs.of (lib.types.submodule (mkSystemModule typ)); - default.value = { }; - }; -in -{ - options = { - systems = { - builders.nixos = mkBuilderOption "nixos"; - builders.darwin = mkBuilderOption "darwin"; - builders.home = mkBuilderOption "home"; - nixos = mkSystemOption "nixos"; - darwin = mkSystemOption "darwin"; - home = mkSystemOption "home"; - }; - }; -} diff --git a/nilla.nix b/nilla.nix index 4379f29..bc20103 100644 --- a/nilla.nix +++ b/nilla.nix @@ -76,42 +76,6 @@ in eval.config.build.wrapper; }; - ci-check = - let - all-packages = builtins.attrValues (builtins.removeAttrs config.packages [ "ci-check" ]); - all-packages' = lib.lists.flatten (map (pkg: builtins.attrValues pkg.result) all-packages); - - nixos-systems = builtins.attrValues config.systems.nixos; - nixos-systems' = map (system: system.result.config.system.build.toplevel) nixos-systems; - - darwin-systems = builtins.attrValues config.systems.darwin; - darwin-systems' = map (system: system.result.config.system.build.toplevel) darwin-systems; - - all-drvs = all-packages' ++ nixos-systems' ++ darwin-systems'; - all-drvs' = lib.strings.concatMapSep "\n" builtins.unsafeDiscardStringContext all-drvs; - in - mkPackage ( - { - lib, - stdenvNoCC, - system, - }: - stdenvNoCC.mkDerivation { - name = "nilla-eval-check"; - src = lib.cleanSource ./.; - doCheck = true; - - allDerivations = all-drvs'; - formatter = lib.getExe config.packages.formatter.result.${system}; - - passAsFile = [ "allDerivations" ]; - - installPhase = ''touch "$out"''; - checkPhase = '' - "$formatter" --ci - ''; - } - ); }; config.shells.default = {