From 9b95b7fce3a8b4f995ba01f0682828dc6b0ccea8 Mon Sep 17 00:00:00 2001 From: Victor Borja Date: Fri, 6 Feb 2026 04:04:37 -0600 Subject: [PATCH] minimal example without flake-parts --- .github/workflows/test.yml | 24 ++++++++++++++++++++++ modules/aspects/provides/ci-noboot.nix | 9 ++++++++ modules/output.nix | 11 ++++++++++ templates/bogus/.github/workflows/test.yml | 2 +- templates/bogus/modules/test-base.nix | 6 +++--- templates/default/modules/ci.nix | 20 ------------------ templates/minimal/flake.lock | 21 ------------------- templates/minimal/flake.nix | 10 +++++---- templates/minimal/modules/den.nix | 16 +++++++++++++-- templates/noflake/modules/compat.nix | 11 ---------- templates/noflake/modules/den.nix | 7 +++---- 11 files changed, 71 insertions(+), 66 deletions(-) create mode 100644 modules/aspects/provides/ci-noboot.nix create mode 100644 modules/output.nix delete mode 100644 templates/default/modules/ci.nix delete mode 100644 templates/noflake/modules/compat.nix diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1dd0872..369df29 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,31 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - uses: actions/checkout@v4 - run: sed -i 's@# den.outPath@den.outPath@' templates/noflake/with-inputs.nix + - run: | + cat <<-EOF > templates/noflake/modules/ci-runtime.nix + { + _module.args.CI = true; + } + EOF + git add templates/noflake/modules/ci-runtime.nix - run: cd templates/noflake && nix-build -A nixosConfigurations.igloo.config.system.build.toplevel + minimal: + needs: [non-draft] + name: minimal + runs-on: ubuntu-latest + steps: + - uses: wimpysworld/nothing-but-nix@main + - uses: cachix/install-nix-action@v31 + - uses: DeterminateSystems/magic-nix-cache-action@v13 + - uses: actions/checkout@v4 + - run: | + cat <<-EOF > templates/minimal/modules/ci-runtime.nix + { + _module.args.CI = true; + } + EOF + git add templates/minimal/modules/ci-runtime.nix + - run: nix flake check ./templates/minimal --override-input den github:$GITHUB_REPOSITORY/$GITHUB_SHA template: needs: [non-draft] strategy: diff --git a/modules/aspects/provides/ci-noboot.nix b/modules/aspects/provides/ci-noboot.nix new file mode 100644 index 0000000..52a8868 --- /dev/null +++ b/modules/aspects/provides/ci-noboot.nix @@ -0,0 +1,9 @@ +{ config, lib, ... }: +{ + den.default.includes = lib.optionals (config ? _module.args.CI) [ + { + nixos.fileSystems."/".device = lib.mkDefault "/dev/noroot"; + nixos.boot.loader.grub.enable = lib.mkDefault false; + } + ]; +} diff --git a/modules/output.nix b/modules/output.nix new file mode 100644 index 0000000..734ef10 --- /dev/null +++ b/modules/output.nix @@ -0,0 +1,11 @@ +{ inputs, lib, ... }: +if inputs ? flake-parts then + { } +else + { + # NOTE: Currently Den needs a top-level attribute where to place configurations, + # by default it is the `flake` attribute, even if Den uses no flake-parts at all. + options.flake = lib.mkOption { + type = lib.types.submodule { freeformType = lib.types.anything; }; + }; + } diff --git a/templates/bogus/.github/workflows/test.yml b/templates/bogus/.github/workflows/test.yml index df3b41d..424a982 100644 --- a/templates/bogus/.github/workflows/test.yml +++ b/templates/bogus/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - uses: wimpysworld/nothing-but-nix@main if: matrix.os == 'ubuntu-latest' - uses: cachix/install-nix-action@v31 - - uses: DeterminateSystems/magic-nix-cache-action@13 + - uses: DeterminateSystems/magic-nix-cache-action@v13 - uses: actions/checkout@v5 - run: nix flake metadata - run: nix flake check diff --git a/templates/bogus/modules/test-base.nix b/templates/bogus/modules/test-base.nix index de076a5..0e31494 100644 --- a/templates/bogus/modules/test-base.nix +++ b/templates/bogus/modules/test-base.nix @@ -1,4 +1,4 @@ -{ den, ... }: +{ den, lib, ... }: { den.default.nixos.system.stateVersion = "25.11"; den.default.homeManager.home.stateVersion = "25.11"; @@ -11,7 +11,7 @@ ]; den.aspects.no-boot.nixos = { - boot.loader.grub.enable = false; - fileSystems."/".device = "/dev/fake"; + boot.loader.grub.enable = lib.mkForce false; + fileSystems."/".device = lib.mkForce "/dev/fake"; }; } diff --git a/templates/default/modules/ci.nix b/templates/default/modules/ci.nix deleted file mode 100644 index 04afb6b..0000000 --- a/templates/default/modules/ci.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ config, ... }: -{ - - den.default.includes = [ - - # USER TODO: Remove. - ( - # This is a conditional aspect to disable boot during CI on all hosts. - if config ? _module.args.CI then - { - nixos.fileSystems."/".device = "/dev/fake"; - nixos.boot.loader.grub.enable = false; - } - else - { } - ) - - ]; - -} diff --git a/templates/minimal/flake.lock b/templates/minimal/flake.lock index cd5ba09..5363f82 100644 --- a/templates/minimal/flake.lock +++ b/templates/minimal/flake.lock @@ -30,26 +30,6 @@ "type": "github" } }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1762980239, - "narHash": "sha256-8oNVE8TrD19ulHinjaqONf9QWCKK+w4url56cdStMpM=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "52a2caecc898d0b46b2b905f058ccc5081f842da", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, "import-tree": { "locked": { "lastModified": 1763263999, @@ -85,7 +65,6 @@ "inputs": { "den": "den", "flake-aspects": "flake-aspects", - "flake-parts": "flake-parts", "import-tree": "import-tree", "nixpkgs": "nixpkgs" } diff --git a/templates/minimal/flake.nix b/templates/minimal/flake.nix index ecf30c0..288eeb2 100644 --- a/templates/minimal/flake.nix +++ b/templates/minimal/flake.nix @@ -1,11 +1,13 @@ { - outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); + outputs = + inputs: + (inputs.nixpkgs.lib.evalModules { + modules = [ (inputs.import-tree ./modules) ]; + specialArgs = { inherit inputs; }; + }).config.flake; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - flake-parts.url = "github:hercules-ci/flake-parts"; - flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; - import-tree.url = "github:vic/import-tree"; flake-aspects.url = "github:vic/flake-aspects"; den.url = "github:vic/den"; diff --git a/templates/minimal/modules/den.nix b/templates/minimal/modules/den.nix index bfafa0a..291240e 100644 --- a/templates/minimal/modules/den.nix +++ b/templates/minimal/modules/den.nix @@ -1,8 +1,20 @@ { inputs, den, ... }: { - systems = builtins.attrNames den.hosts; + # we can import this flakeModule even if we dont have flake-parts as input! imports = [ inputs.den.flakeModule ]; den.hosts.x86_64-linux.igloo.users.tux = { }; - den.aspects.igloo = { }; + + den.aspects.igloo = { + nixos = + { pkgs, ... }: + { + environment.systemPackages = [ pkgs.hello ]; + passthru = { }; + }; + }; + + den.aspects.tux = { + includes = [ den.provides.primary-user ]; + }; } diff --git a/templates/noflake/modules/compat.nix b/templates/noflake/modules/compat.nix deleted file mode 100644 index 0df2f5f..0000000 --- a/templates/noflake/modules/compat.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ inputs, lib, ... }: -{ - # we can import this flakeModule even if we dont have flake-parts as input! - imports = [ inputs.den.flakeModule ]; - - # NOTE: Currently Den needs a top-level attribute where to place configurations, - # by default it is the `flake` attribute, even if Den uses no flake-parts at all. - options.flake = lib.mkOption { - type = lib.types.submodule { freeformType = lib.types.anything; }; - }; -} diff --git a/templates/noflake/modules/den.nix b/templates/noflake/modules/den.nix index 4ab46f5..f59b099 100644 --- a/templates/noflake/modules/den.nix +++ b/templates/noflake/modules/den.nix @@ -1,5 +1,8 @@ { inputs, ... }: { + # we can import this flakeModule even if we dont have flake-parts as input! + imports = [ inputs.den.flakeModule ]; + # tux user on igloo host. den.hosts.x86_64-linux.igloo.users.tux = { }; @@ -8,11 +11,7 @@ nixos = { pkgs, ... }: { - # remove these for a real bootable host - boot.loader.grub.enable = false; - fileSystems."/".device = "/dev/fake"; passthru = { }; - environment.systemPackages = [ pkgs.vim ];