mirror of
https://github.com/divnix/digga.git
synced 2024-12-23 16:11:51 +03:00
deploy: ed17d9e99f
This commit is contained in:
parent
399243e54b
commit
d20a6c3415
20
flake.nix
20
flake.nix
@ -40,15 +40,19 @@
|
|||||||
inherit extern overrides;
|
inherit extern overrides;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
suites = os.mkSuites {
|
||||||
|
suites = import ./suites;
|
||||||
|
users = os.mkProfileAttrs "${self}/users";
|
||||||
|
profiles = os.mkProfileAttrs "${self}/profiles";
|
||||||
|
userProfiles = os.mkProfileAttrs "${self}/users/profiles";
|
||||||
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
nixosConfigurations =
|
nixosConfigurations = os.mkHosts {
|
||||||
import ./hosts (nixos.lib.recursiveUpdate inputs {
|
dir = "${self}/hosts";
|
||||||
inherit multiPkgs extern;
|
overrides = import ./overrides;
|
||||||
defaultSystem = "x86_64-linux";
|
inherit multiPkgs suites extern;
|
||||||
lib = nixos.lib.extend (final: prev: {
|
};
|
||||||
dev = self.lib;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
homeConfigurations = os.mkHomeConfigurations;
|
homeConfigurations = os.mkHomeConfigurations;
|
||||||
|
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
mkNodes = dev.callLibs ./mkNodes.nix;
|
mkNodes = dev.callLibs ./mkNodes.nix;
|
||||||
|
|
||||||
|
mkHosts = dev.callLibs ./mkHosts.nix;
|
||||||
|
|
||||||
|
mkSuites = dev.callLibs ./mkSuites.nix;
|
||||||
|
|
||||||
mkProfileAttrs = dev.callLibs ./mkProfileAttrs.nix;
|
mkProfileAttrs = dev.callLibs ./mkProfileAttrs.nix;
|
||||||
|
|
||||||
mkPkgs = dev.callLibs ./mkPkgs.nix;
|
mkPkgs = dev.callLibs ./mkPkgs.nix;
|
||||||
|
@ -18,7 +18,10 @@ lib.nixosSystem (args // {
|
|||||||
({ config, suites, ... }: {
|
({ config, suites, ... }: {
|
||||||
|
|
||||||
# avoid unwanted systemd service startups
|
# avoid unwanted systemd service startups
|
||||||
disabledModules = lib.remove modules.core suites.allProfiles;
|
# all strings in disabledModules get appended to modulesPath
|
||||||
|
# so convert each to list which can be coerced to string
|
||||||
|
disabledModules = map (x: [ x ])
|
||||||
|
(lib.remove modules.core suites.allProfiles);
|
||||||
|
|
||||||
nix.registry = lib.mapAttrs (n: v: { flake = v; }) inputs;
|
nix.registry = lib.mapAttrs (n: v: { flake = v; }) inputs;
|
||||||
|
|
||||||
|
@ -1,17 +1,8 @@
|
|||||||
{ extern
|
{ lib, dev, nixos, inputs, self, ... }:
|
||||||
, home
|
|
||||||
, lib
|
|
||||||
, nixos
|
|
||||||
, override
|
|
||||||
, multiPkgs
|
|
||||||
, self
|
|
||||||
, defaultSystem
|
|
||||||
, ...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inherit (lib) dev;
|
|
||||||
|
|
||||||
suites = import ../suites { inherit lib; };
|
{ dir, extern, suites, overrides, multiPkgs, ... }:
|
||||||
|
let
|
||||||
|
defaultSystem = "x86_64-linux";
|
||||||
|
|
||||||
experimentalFeatures = [
|
experimentalFeatures = [
|
||||||
"flakes"
|
"flakes"
|
||||||
@ -21,10 +12,9 @@ let
|
|||||||
];
|
];
|
||||||
|
|
||||||
modules = {
|
modules = {
|
||||||
core = ../profiles/core;
|
core = "${self}/profiles/core";
|
||||||
modOverrides = { config, overrideModulesPath, ... }:
|
modOverrides = { config, overrideModulesPath, ... }:
|
||||||
let
|
let
|
||||||
overrides = import ../overrides;
|
|
||||||
inherit (overrides) modules disabledModules;
|
inherit (overrides) modules disabledModules;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@ -48,7 +38,7 @@ let
|
|||||||
nix.nixPath = [
|
nix.nixPath = [
|
||||||
"nixpkgs=${nixos}"
|
"nixpkgs=${nixos}"
|
||||||
"nixos-config=${self}/compat/nixos"
|
"nixos-config=${self}/compat/nixos"
|
||||||
"home-manager=${home}"
|
"home-manager=${inputs.home}"
|
||||||
];
|
];
|
||||||
|
|
||||||
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
|
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
|
||||||
@ -56,7 +46,7 @@ let
|
|||||||
nix.registry = {
|
nix.registry = {
|
||||||
devos.flake = self;
|
devos.flake = self;
|
||||||
nixos.flake = nixos;
|
nixos.flake = nixos;
|
||||||
override.flake = override;
|
override.flake = inputs.override;
|
||||||
};
|
};
|
||||||
|
|
||||||
nix.extraOptions = ''
|
nix.extraOptions = ''
|
||||||
@ -71,7 +61,7 @@ let
|
|||||||
# Everything in `./modules/list.nix`.
|
# Everything in `./modules/list.nix`.
|
||||||
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
|
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
|
||||||
|
|
||||||
cachix = ../cachix.nix;
|
cachix = ../../cachix.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
specialArgs = extern.specialArgs // { suites = suites.system; };
|
specialArgs = extern.specialArgs // { suites = suites.system; };
|
||||||
@ -80,7 +70,7 @@ let
|
|||||||
let
|
let
|
||||||
local = {
|
local = {
|
||||||
require = [
|
require = [
|
||||||
"${toString ./.}/${hostName}.nix"
|
"${dir}/${hostName}.nix"
|
||||||
];
|
];
|
||||||
|
|
||||||
networking = { inherit hostName; };
|
networking = { inherit hostName; };
|
||||||
@ -106,7 +96,7 @@ let
|
|||||||
|
|
||||||
hosts = dev.os.recImport
|
hosts = dev.os.recImport
|
||||||
{
|
{
|
||||||
dir = ./.;
|
inherit dir;
|
||||||
_import = mkHostConfig;
|
_import = mkHostConfig;
|
||||||
};
|
};
|
||||||
in
|
in
|
@ -27,7 +27,7 @@ let mkProfileAttrs =
|
|||||||
f = n: _:
|
f = n: _:
|
||||||
lib.optionalAttrs
|
lib.optionalAttrs
|
||||||
(lib.pathExists "${dir}/${n}/default.nix")
|
(lib.pathExists "${dir}/${n}/default.nix")
|
||||||
{ default = /. + "${dir}/${n}"; }
|
{ default = "${dir}/${n}"; }
|
||||||
// mkProfileAttrs "${dir}/${n}";
|
// mkProfileAttrs "${dir}/${n}";
|
||||||
in
|
in
|
||||||
lib.mapAttrs f imports;
|
lib.mapAttrs f imports;
|
||||||
|
24
lib/devos/mkSuites.nix
Normal file
24
lib/devos/mkSuites.nix
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{ lib, dev, ... }:
|
||||||
|
|
||||||
|
{ users, profiles, userProfiles, suites } @ args:
|
||||||
|
let
|
||||||
|
inherit (dev) os;
|
||||||
|
|
||||||
|
definedSuites = suites {
|
||||||
|
inherit (args) users profiles userProfiles;
|
||||||
|
};
|
||||||
|
|
||||||
|
allProfiles =
|
||||||
|
let defaults = lib.collect (x: x ? default) profiles;
|
||||||
|
in map (x: x.default) defaults;
|
||||||
|
|
||||||
|
allUsers =
|
||||||
|
let defaults = lib.collect (x: x ? default) users;
|
||||||
|
in map (x: x.default) defaults;
|
||||||
|
|
||||||
|
createSuites = _: suites: lib.mapAttrs (_: v: os.profileMap v) suites // {
|
||||||
|
inherit allProfiles allUsers;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
lib.mapAttrs createSuites definedSuites
|
@ -1,35 +1,10 @@
|
|||||||
{ lib }:
|
{ users, profiles, userProfiles, ... }:
|
||||||
let
|
|
||||||
inherit (lib) dev;
|
|
||||||
|
|
||||||
profiles = dev.os.mkProfileAttrs (toString ../profiles);
|
{
|
||||||
userProfiles = dev.os.mkProfileAttrs (toString ../users/profiles);
|
system = with profiles; rec {
|
||||||
users = dev.os.mkProfileAttrs (toString ../users);
|
|
||||||
|
|
||||||
allProfiles =
|
|
||||||
let defaults = lib.collect (x: x ? default) profiles;
|
|
||||||
in map (x: x.default) defaults;
|
|
||||||
|
|
||||||
allUsers =
|
|
||||||
let defaults = lib.collect (x: x ? default) users;
|
|
||||||
in map (x: x.default) defaults;
|
|
||||||
|
|
||||||
|
|
||||||
suites = with profiles; rec {
|
|
||||||
base = [ users.nixos users.root ];
|
base = [ users.nixos users.root ];
|
||||||
};
|
};
|
||||||
|
user = with userProfiles; rec {
|
||||||
# available as 'suites' within the home-manager configuration
|
|
||||||
userSuites = with userProfiles; rec {
|
|
||||||
base = [ direnv git ];
|
base = [ direnv git ];
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
|
||||||
{
|
|
||||||
system = lib.mapAttrs (_: v: dev.os.profileMap v) suites // {
|
|
||||||
inherit allProfiles allUsers;
|
|
||||||
};
|
|
||||||
user = lib.mapAttrs (_: v: dev.os.profileMap v) userSuites // {
|
|
||||||
allProfiles = userProfiles;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,24 @@ lib.runTests {
|
|||||||
(rgxToString "a?" "a" == "a")
|
(rgxToString "a?" "a" == "a")
|
||||||
(rgxToString "hat" "foohatbar" == "hat")
|
(rgxToString "hat" "foohatbar" == "hat")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
testSuites =
|
||||||
|
let
|
||||||
|
profiles = os.mkProfileAttrs (toString ./profiles);
|
||||||
|
users = "";
|
||||||
|
userProfiles = "";
|
||||||
|
suites = { profiles, ... }: {
|
||||||
|
system.bar = [ profiles.foo ];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
expr = os.mkSuites { inherit profiles users userProfiles suites; };
|
||||||
|
expected = {
|
||||||
|
system = {
|
||||||
|
bar = [ profiles.foo.default ];
|
||||||
|
allProfiles = [ profiles.foo.default profiles.t.default ];
|
||||||
|
allUsers = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
3
tests/profiles/foo/default.nix
Normal file
3
tests/profiles/foo/default.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
bar = 5;
|
||||||
|
}
|
0
tests/profiles/t/default.nix
Normal file
0
tests/profiles/t/default.nix
Normal file
Loading…
Reference in New Issue
Block a user