PoC working SP module system
+ simple-nixos-mailserver as an SP module
This commit is contained in:
84
flake.nix
84
flake.nix
@@ -9,40 +9,54 @@
|
||||
selfprivacy-graphql-api.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, selfprivacy-graphql-api }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
in
|
||||
{
|
||||
nixosConfigurations-fun =
|
||||
{ hardware-configuration
|
||||
, userdata
|
||||
, top-level-flake
|
||||
}: {
|
||||
just-nixos = nixpkgs.lib.nixosSystem {
|
||||
specialArgs = {
|
||||
inherit
|
||||
system
|
||||
hardware-configuration
|
||||
userdata;
|
||||
selfprivacy-graphql-api =
|
||||
selfprivacy-graphql-api.packages.${system}.default;
|
||||
};
|
||||
modules = [
|
||||
hardware-configuration
|
||||
./configuration.nix
|
||||
{
|
||||
# embed top-level flake source folder into the build
|
||||
environment.etc."selfprivacy-config-source" =
|
||||
top-level-flake.outPath;
|
||||
# for running "nix search nixpkgs", etc
|
||||
nix.registry.nixpkgs.flake = nixpkgs;
|
||||
# embed commit sha1; dirty builds are intentionally forbidden
|
||||
system.configurationRevision = self.rev;
|
||||
}
|
||||
];
|
||||
inherit system;
|
||||
};
|
||||
outputs = { self, nixpkgs, selfprivacy-graphql-api }: {
|
||||
nixosConfigurations-fun =
|
||||
{ system
|
||||
, hardware-configuration
|
||||
, userdata
|
||||
, top-level-flake
|
||||
, sp-modules
|
||||
}:
|
||||
let
|
||||
lib = nixpkgs.legacyPackages.${system}.lib;
|
||||
in
|
||||
{
|
||||
inherit system;
|
||||
just-nixos = nixpkgs.lib.nixosSystem {
|
||||
specialArgs = { inherit system; };
|
||||
modules = [
|
||||
hardware-configuration
|
||||
./configuration.nix
|
||||
(import ./userdata-variables.nix userdata)
|
||||
(import ./api/api-module.nix
|
||||
selfprivacy-graphql-api.packages.${system}.default)
|
||||
{
|
||||
# embed top-level flake source folder into the build
|
||||
environment.etc."selfprivacy-config-source".source =
|
||||
top-level-flake.outPath;
|
||||
# for running "nix search nixpkgs", etc
|
||||
nix.registry.nixpkgs.flake = nixpkgs;
|
||||
# embed commit sha1; FIXME dirty builds must be intentionally forbidden
|
||||
system.configurationRevision = self.rev or ("#" + self.lastModifiedDate + "-" + toString self.lastModified);
|
||||
}
|
||||
]
|
||||
++
|
||||
# add SP modules, but filter available config attributes for each
|
||||
map
|
||||
(sp-module: args@{ pkgs, ... }: (sp-module.nixosModules.default
|
||||
(args // {
|
||||
config =
|
||||
# TODO use lib.attrsets.mergeAttrsList from nixpkgs 23.05
|
||||
(builtins.foldl' lib.trivial.mergeAttrs { }
|
||||
(map
|
||||
(p: lib.attrsets.setAttrByPath p
|
||||
(lib.attrsets.getAttrFromPath p args.config))
|
||||
sp-module.configPathsNeeded));
|
||||
}))
|
||||
)
|
||||
# (sp-module: sp-module.nixosModules.default)
|
||||
(lib.attrsets.attrValues sp-modules);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user