Compare commits

...

2 commits

Author SHA1 Message Date
Valentin Gagarin 591dd87752 deduplicate 2024-09-25 12:23:34 +02:00
Valentin Gagarin cc3ccbc59a use stable CLI for deploying 2024-09-25 12:23:27 +02:00
3 changed files with 40 additions and 112 deletions

View file

@ -1,8 +1,8 @@
let
inputs = import ./npins;
system = "x86_64-linux";
pkgs = import inputs.nixpkgs { config = { }; overlays = [ ]; system = builtins.currentSystem; };
lib = import "${inputs.nixpkgs}/lib" // { inherit nixosSystem; };
{ inputs ? import ./npins
, system ? builtins.currentSystem
, pkgs ? import inputs.nixpkgs { config = { }; overlays = [ ]; inherit system; }
, lib ? import "${inputs.nixpkgs}/lib"
// {
nixosSystem = args:
import "${inputs.nixpkgs}/nixos/lib/eval-config.nix"
(
@ -17,7 +17,9 @@ let
}
// builtins.removeAttrs args [ "modules" ]
);
in
}
,
}:
rec {
nixosModules = {
disko = "${inputs.disko}/module.nix";
@ -31,7 +33,7 @@ rec {
# test with
# nix-build -A nixosConfigurations.<config>.installTest
nixosConfigurations = {
mastodon = nixosSystem {
mastodon = lib.nixosSystem {
inherit system;
modules = with nixosModules; [
disko
@ -41,7 +43,7 @@ rec {
];
};
peertube = nixosSystem {
peertube = lib.nixosSystem {
inherit system;
modules = with nixosModules; [
disko
@ -51,7 +53,7 @@ rec {
];
};
pixelfed = nixosSystem {
pixelfed = lib.nixosSystem {
inherit system;
modules = with nixosModules; [
disko
@ -61,7 +63,7 @@ rec {
];
};
all = nixosSystem {
all = lib.nixosSystem {
inherit system;
modules = with nixosModules; [
interactive-vm

View file

@ -3,7 +3,7 @@ name: config:
writeShellApplication {
name = "deploy";
text = ''
result="$(nix build ${./.}#nixosConfigurations.${name} --eval-store auto --store ssh-ng://${name})"
result="$(nix-build ${./.} -A nixosConfigurations.${name} --eval-store auto --store ssh-ng://${name})"
# shellcheck disable=SC2087
ssh ${name} << EOF
nix-env -p /nix/var/nix/profiles/system --set "$result"

View file

@ -6,99 +6,25 @@
disko.url = "github:nix-community/disko";
};
outputs = { self, nixpkgs, disko, ... }:
outputs = inputs@{ self, nixpkgs, disko, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
default = import ./default.nix { inherit system inputs; };
in {
nixosModules = {
## Fediversity modules
fediversity = import ./fediversity;
## VM-specific modules
inherit (disko.nixosModules) disko;
disk-layout = import ./vm/disk-layout.nix;
interactive-vm = import ./vm/interactive-vm.nix;
mastodon-vm = import ./vm/mastodon-vm.nix;
peertube-vm = import ./vm/peertube-vm.nix;
pixelfed-vm = import ./vm/pixelfed-vm.nix;
};
nixosConfigurations = {
mastodon = nixpkgs.lib.nixosSystem {
inherit system;
modules = with self.nixosModules; [
disko
disk-layout
fediversity
interactive-vm
mastodon-vm
];
};
peertube = nixpkgs.lib.nixosSystem {
inherit system;
modules = with self.nixosModules; [
disko
disk-layout
fediversity
interactive-vm
peertube-vm
];
};
pixelfed = nixpkgs.lib.nixosSystem {
inherit system;
modules = with self.nixosModules; [
disko
disk-layout
fediversity
interactive-vm
pixelfed-vm
];
};
all = nixpkgs.lib.nixosSystem {
inherit system;
modules = with self.nixosModules; [
disko
disk-layout
fediversity
interactive-vm
peertube-vm
pixelfed-vm
mastodon-vm
];
};
};
inherit (default)
nixosModules
nixosConfigurations
# build with
# nix build .#installers.<config>
installers =
let
installer = (import ./installer.nix) nixpkgs;
in
nixpkgs.lib.mapAttrs (_: config: installer config) self.nixosConfigurations;
installers
# run with
# nix run .#deploy.<machine>
deploy =
let
deployCommand = (pkgs.callPackage ./deploy.nix {});
in
nixpkgs.lib.mapAttrs (name: config: deployCommand name config) self.nixosConfigurations;
deploy
;
checks.${system} = {
mastodon-garage = import ./tests/mastodon-garage.nix { inherit pkgs; };
pixelfed-garage = import ./tests/pixelfed-garage.nix { inherit pkgs; };
};
checks.${system} = default.tests;
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
nil
];
};
devShells.${system}.default = default.shell;
};
}