From f553fe9e05ded2de6b9b1da83a115e8ad8dc7498 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Fri, 24 May 2024 18:34:32 +0200 Subject: [PATCH] feat: achieve custom evaluation in the framework Signed-off-by: Ryan Lahfa --- hive.nix | 100 +++++++++++------- liminix-hive.nix | 38 ------- .../_configuration.nix} | 0 machines/ap01/_hardware-configuration.nix | 1 + npins/default.nix | 1 + npins/sources.json | 24 +++-- 6 files changed, 81 insertions(+), 83 deletions(-) delete mode 100644 liminix-hive.nix rename machines/{ap/configuration.nix => ap01/_configuration.nix} (100%) create mode 100644 machines/ap01/_hardware-configuration.nix diff --git a/hive.nix b/hive.nix index 35e43e3..3c52d10 100644 --- a/hive.nix +++ b/hive.nix @@ -4,6 +4,8 @@ let # Patch sources directly sources = builtins.mapAttrs (patch.base { pkgs = import sources'.nixos-unstable { }; }) .applyPatches' sources'; + lib = import (sources.nix-lib + "/src/trivial.nix"); + lib' = (import sources.nixos-unstable { }).lib; nix-lib = import ./lib/nix-lib; @@ -14,7 +16,12 @@ let mkNode = node: { # Import the base configuration for each node - imports = [ ./machines/${node}/_configuration.nix ]; + imports = builtins.map (lib.mkRel (./machines/${node})) [ + "_configuration.nix" + "_hardware-configuration.nix" + ]; + + deployment.systemType = systemType node; }; nixpkgs' = import ./meta/nixpkgs.nix; @@ -28,6 +35,10 @@ let # defaulting to the one defined in meta/nixpkgs version = node: nodes'.${node}.nixpkgs or nixpkgs'.versions.default; system = node: nodes'.${node}.system or nixpkgs'.systems.default; + systemType = + node: + nodes'.${node}.system + or (lib'.warn "Not specifying the `deployment.systemType` is deprecated!" "nixos"); # Builds a patched version of nixpkgs, only as the source mkNixpkgs' = @@ -85,8 +96,57 @@ in { registry = { - liminix = { + zyxel-nwa50ax = { evalConfig = import "${sources.liminix}/lib/eval-config.nix" { nixpkgs = sources.nixos-unstable; }; + + defaults = { + nixpkgs.hostPlatform = { + config = "mipsel-unknown-linux-musl"; + gcc = { + abi = "32"; + arch = "mips32"; # mips32r2? + }; + }; + # It's impure, but who cares? + # Can Flakes do that? + nixpkgs.buildPlatform = builtins.currentSystem; + }; + }; + + nixos = { + evalConfig = import "${sources.nixos-unstable}/nixos/lib/eval-config.nix"; + defaults = + { nodeMeta, name, ... }: + { + # Import the default modules + imports = [ ./modules ]; + + # Include default secrets + age-secrets.sources = [ ./machines/${name}/secrets ]; + + # Deployment config is specified in meta.nodes.${node}.deployment + inherit (nodeMeta) deployment; + + nix = { + # Set NIX_PATH to the patched version of nixpkgs + nixPath = [ "nixpkgs=${mkNixpkgs' (version name)}" ]; + optimise.automatic = true; + + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # Use the stateVersion declared in the metadata + system = { + inherit (nodeMeta) stateVersion; + }; + }; }; }; @@ -104,42 +164,6 @@ in nodeSpecialArgs = nix-lib.mapSingleFuse mkArgs nodes; }; - registry.nixos.defaults = - { nodeMeta, name, ... }: - { - # Import the default modules - imports = [ - ./modules - (import "${sources.lix-module}/module.nix" { inherit (sources) lix; }) - ]; - - # Include default secrets - age-secrets.sources = [ ./machines/${name}/secrets ]; - - # Deployment config is specified in meta.nodes.${node}.deployment - inherit (nodeMeta) deployment; - - nix = { - # Set NIX_PATH to the patched version of nixpkgs - nixPath = [ "nixpkgs=${mkNixpkgs' (version name)}" ]; - optimise.automatic = true; - - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 7d"; - }; - }; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - # Use the stateVersion declared in the metadata - system = { - inherit (nodeMeta) stateVersion; - }; - }; - ap01 = let device = import "${sources.liminix}/devices/zyxel-nwa50ax"; diff --git a/liminix-hive.nix b/liminix-hive.nix deleted file mode 100644 index a9be921..0000000 --- a/liminix-hive.nix +++ /dev/null @@ -1,38 +0,0 @@ -# This is a very rudimentary hive to deploy Liminix images. -{ - sources ? import ./npins, - nixpkgs ? sources.nixpkgs, - liminix ? sources.liminix, -}: -let - evalLiminix = - { config, device }: - { - primary = import liminix { - inherit device nixpkgs; - imageType = "primary"; - liminix-config = config; - }; - secondary = import liminix { - inherit device nixpkgs; - imageType = "secondary"; - liminix-config = config; - }; - }; - zyxel = { - nwa50ax = import "${liminix}/devices/zyxel-nwa50ax"; - }; -in -{ - liminix.pkgs = - (import liminix { - device = zyxel.nwa50ax; - imageType = "primary"; - liminix-config = ./machines/ap/configuration.nix; - }).pkgs; - devices = zyxel; - ap-test = evalLiminix { - config = ./machines/ap/configuration.nix; - device = zyxel.nwa50ax; - }; -} diff --git a/machines/ap/configuration.nix b/machines/ap01/_configuration.nix similarity index 100% rename from machines/ap/configuration.nix rename to machines/ap01/_configuration.nix diff --git a/machines/ap01/_hardware-configuration.nix b/machines/ap01/_hardware-configuration.nix new file mode 100644 index 0000000..ffcd441 --- /dev/null +++ b/machines/ap01/_hardware-configuration.nix @@ -0,0 +1 @@ +{ } diff --git a/npins/default.nix b/npins/default.nix index 43cead3..14589ce 100644 --- a/npins/default.nix +++ b/npins/default.nix @@ -42,6 +42,7 @@ let builtins.fetchGit { inherit (repository) url; rev = revision; + allRefs = true; # hash = hash; }; diff --git a/npins/sources.json b/npins/sources.json index 050f46a..ca37142 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -49,6 +49,17 @@ "url": null, "hash": "0b1pmfzckdbha9j7bvnkvqccf62dqyll8ip6mrdm90m0y8kdkzvg" }, + "colmena": { + "type": "Git", + "repository": { + "type": "Git", + "url": "https://git.dgnum.eu/DGNum/colmena.git" + }, + "branch": "custom-activation", + "revision": "937ca4d17aecd3ae7394a2a1772dd3e705cb5779", + "url": null, + "hash": "11n9qdm0zi3s89zdcdmyv4l4wv5aq8b4sigx54cp24plxszxrsa7" + }, "disko": { "type": "GitRelease", "repository": { @@ -116,14 +127,13 @@ "liminix": { "type": "Git", "repository": { - "type": "GitHub", - "owner": "RaitoBezarius", - "repo": "liminix" + "type": "Git", + "url": "https://git.dgnum.eu/DGNum/liminix.git" }, - "branch": "colmena--compat", - "revision": "411a6bc688763fe62d210ccfe066a6cea72a9dce", - "url": "https://github.com/RaitoBezarius/liminix/archive/411a6bc688763fe62d210ccfe066a6cea72a9dce.tar.gz", - "hash": "17wg5288z3085rd4day1qqi1pm0cmibmcm6nrqrgrc1w1iwja9f0" + "branch": "main", + "revision": "7ae86c23d96b5e6a59fff4d8ebcb3e2e90e4034f", + "url": null, + "hash": "1kw6jp5xnpwnpl2pal3qpr5ljrsvjish4v4m0brnxchc8s1ygq6i" }, "linkal": { "type": "Git",