add flake-parts module for clan
This commit is contained in:
@@ -1,17 +1,11 @@
|
|||||||
{ self, ... }:
|
{ self, ... }:
|
||||||
{
|
{
|
||||||
flake.clanInternals =
|
clan.machines.test-backup = {
|
||||||
(self.lib.buildClan {
|
|
||||||
clanName = "testclan";
|
|
||||||
directory = ../..;
|
|
||||||
machines.test-backup = {
|
|
||||||
imports = [ self.nixosModules.test-backup ];
|
imports = [ self.nixosModules.test-backup ];
|
||||||
fileSystems."/".device = "/dev/null";
|
fileSystems."/".device = "/dev/null";
|
||||||
boot.loader.grub.device = "/dev/null";
|
boot.loader.grub.device = "/dev/null";
|
||||||
};
|
};
|
||||||
}).clanInternals;
|
|
||||||
flake.nixosModules = {
|
flake.nixosModules = {
|
||||||
|
|
||||||
test-backup =
|
test-backup =
|
||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
@@ -75,7 +69,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
clanCore.facts.secretStore = "vm";
|
clanCore.facts.secretStore = "vm";
|
||||||
clanCore.clanDir = ../..;
|
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
self.packages.${pkgs.system}.clan-cli
|
self.packages.${pkgs.system}.clan-cli
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
{ self, ... }:
|
{ self, lib, ... }:
|
||||||
let
|
{
|
||||||
clan = self.lib.buildClan {
|
clan.machines.test_install_machine = {
|
||||||
clanName = "testclan";
|
|
||||||
directory = ../..;
|
|
||||||
machines = {
|
|
||||||
test_install_machine = {
|
|
||||||
clan.networking.targetHost = "test_install_machine";
|
clan.networking.targetHost = "test_install_machine";
|
||||||
|
fileSystems."/".device = lib.mkDefault "/dev/null";
|
||||||
|
boot.loader.grub.device = lib.mkDefault "/dev/null";
|
||||||
|
|
||||||
imports = [ self.nixosModules.test_install_machine ];
|
imports = [ self.nixosModules.test_install_machine ];
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
flake.nixosConfigurations = {
|
|
||||||
inherit (clan.nixosConfigurations) test_install_machine;
|
|
||||||
};
|
|
||||||
flake.clanInternals = clan.clanInternals;
|
|
||||||
flake.nixosModules = {
|
flake.nixosModules = {
|
||||||
test_install_machine =
|
test_install_machine =
|
||||||
{ lib, modulesPath, ... }:
|
{ lib, modulesPath, ... }:
|
||||||
@@ -43,10 +34,10 @@ in
|
|||||||
let
|
let
|
||||||
dependencies = [
|
dependencies = [
|
||||||
self
|
self
|
||||||
|
self.nixosConfigurations.test_install_machine.config.system.build.toplevel
|
||||||
|
self.nixosConfigurations.test_install_machine.config.system.build.diskoScript
|
||||||
|
self.nixosConfigurations.test_install_machine.config.system.clan.deployment.file
|
||||||
pkgs.stdenv.drvPath
|
pkgs.stdenv.drvPath
|
||||||
clan.clanInternals.machines.x86_64-linux.test_install_machine.config.system.build.toplevel
|
|
||||||
clan.clanInternals.machines.x86_64-linux.test_install_machine.config.system.build.diskoScript
|
|
||||||
clan.clanInternals.machines.x86_64-linux.test_install_machine.config.system.clan.deployment.file
|
|
||||||
pkgs.nixos-anywhere
|
pkgs.nixos-anywhere
|
||||||
] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
|
] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
|
||||||
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
||||||
|
|||||||
17
flake.nix
17
flake.nix
@@ -25,7 +25,7 @@
|
|||||||
outputs =
|
outputs =
|
||||||
inputs@{ flake-parts, ... }:
|
inputs@{ flake-parts, ... }:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } (
|
flake-parts.lib.mkFlake { inherit inputs; } (
|
||||||
{ lib, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
systems = [
|
systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
@@ -35,6 +35,8 @@
|
|||||||
imports = [
|
imports = [
|
||||||
./checks/flake-module.nix
|
./checks/flake-module.nix
|
||||||
./clanModules/flake-module.nix
|
./clanModules/flake-module.nix
|
||||||
|
./flakeModules/flake-module.nix
|
||||||
|
./flakeModules/clan.nix
|
||||||
./devShell.nix
|
./devShell.nix
|
||||||
./docs/flake-module
|
./docs/flake-module
|
||||||
./formatter.nix
|
./formatter.nix
|
||||||
@@ -42,19 +44,6 @@
|
|||||||
./nixosModules/flake-module.nix
|
./nixosModules/flake-module.nix
|
||||||
./pkgs/flake-module.nix
|
./pkgs/flake-module.nix
|
||||||
./templates/flake-module.nix
|
./templates/flake-module.nix
|
||||||
{
|
|
||||||
options.flake = flake-parts.lib.mkSubmoduleOptions {
|
|
||||||
clanInternals = lib.mkOption {
|
|
||||||
type = lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
all-machines-json = lib.mkOption { type = lib.types.attrsOf lib.types.str; };
|
|
||||||
machines = lib.mkOption { type = lib.types.attrsOf (lib.types.attrsOf lib.types.unspecified); };
|
|
||||||
machinesFunc = lib.mkOption { type = lib.types.attrsOf (lib.types.attrsOf lib.types.unspecified); };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
73
flakeModules/clan.nix
Normal file
73
flakeModules/clan.nix
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
flake-parts-lib,
|
||||||
|
inputs,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
buildClan = import ../lib/build-clan {
|
||||||
|
inherit lib;
|
||||||
|
clan-core = self;
|
||||||
|
inherit (inputs) nixpkgs;
|
||||||
|
};
|
||||||
|
|
||||||
|
cfg = config.clan;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.clan = {
|
||||||
|
directory = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
description = "The directory containing the clan subdirectory";
|
||||||
|
};
|
||||||
|
specialArgs = mkOption {
|
||||||
|
type = types.attrsOf types.str;
|
||||||
|
default = { };
|
||||||
|
description = "Extra arguments to pass to nixosSystem i.e. useful to make self available";
|
||||||
|
};
|
||||||
|
machines = mkOption {
|
||||||
|
type = types.attrsOf types.raw;
|
||||||
|
default = { };
|
||||||
|
description = "Allows to include machine-specific modules i.e. machines.\${name} = { ... }";
|
||||||
|
};
|
||||||
|
clanName = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to.";
|
||||||
|
};
|
||||||
|
clanIcon = mkOption {
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
default = null;
|
||||||
|
description = "A path to an icon to be used for the clan, should be the same for all machines";
|
||||||
|
};
|
||||||
|
pkgsForSystem = mkOption {
|
||||||
|
type = types.functionTo types.raw;
|
||||||
|
default = _system: null;
|
||||||
|
description = "A map from arch to pkgs, if specified this nixpkgs will be only imported once for each system.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
options.flake = flake-parts-lib.mkSubmoduleOptions {
|
||||||
|
clanInternals = lib.mkOption {
|
||||||
|
type = lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
all-machines-json = lib.mkOption { type = lib.types.attrsOf lib.types.str; };
|
||||||
|
machines = lib.mkOption { type = lib.types.attrsOf (lib.types.attrsOf lib.types.unspecified); };
|
||||||
|
machinesFunc = lib.mkOption { type = lib.types.attrsOf (lib.types.attrsOf lib.types.unspecified); };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
flake = buildClan {
|
||||||
|
inherit (cfg)
|
||||||
|
directory
|
||||||
|
specialArgs
|
||||||
|
machines
|
||||||
|
clanName
|
||||||
|
clanIcon
|
||||||
|
pkgsForSystem
|
||||||
|
;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
7
flakeModules/flake-module.nix
Normal file
7
flakeModules/flake-module.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
flake.flakeModules = {
|
||||||
|
clan = ./clan.nix;
|
||||||
|
default = config.flake.flakeModules.clan;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -18,21 +18,21 @@ let
|
|||||||
{ disko.memSize = 4096; } # FIXME: otherwise the image builder goes OOM
|
{ disko.memSize = 4096; } # FIXME: otherwise the image builder goes OOM
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
clan = self.lib.buildClan {
|
|
||||||
clanName = "clan-core";
|
|
||||||
directory = self;
|
|
||||||
machines.installer = installerModule;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
flake.packages.x86_64-linux.install-iso = self.inputs.disko.lib.makeDiskImages {
|
flake.packages.x86_64-linux.install-iso = self.inputs.disko.lib.makeDiskImages {
|
||||||
nixosConfig = installer;
|
nixosConfig = installer;
|
||||||
};
|
};
|
||||||
flake.nixosConfigurations = {
|
|
||||||
inherit (clan.nixosConfigurations) installer;
|
clan = {
|
||||||
|
clanName = "clan-core";
|
||||||
|
directory = self;
|
||||||
|
machines.installer = {
|
||||||
|
imports = [ installerModule ];
|
||||||
|
fileSystems."/".device = lib.mkDefault "/dev/null";
|
||||||
|
boot.loader.grub.device = lib.mkDefault "/dev/null";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
flake.clanInternals = clan.clanInternals;
|
|
||||||
flake.apps.x86_64-linux.install-vm.program = installer.config.formats.vm.outPath;
|
flake.apps.x86_64-linux.install-vm.program = installer.config.formats.vm.outPath;
|
||||||
flake.apps.x86_64-linux.install-vm-nogui.program = installer.config.formats.vm-nogui.outPath;
|
flake.apps.x86_64-linux.install-vm-nogui.program = installer.config.formats.vm-nogui.outPath;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user