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

View file

@ -3,7 +3,7 @@ name: config:
writeShellApplication { writeShellApplication {
name = "deploy"; name = "deploy";
text = '' 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 # shellcheck disable=SC2087
ssh ${name} << EOF ssh ${name} << EOF
nix-env -p /nix/var/nix/profiles/system --set "$result" nix-env -p /nix/var/nix/profiles/system --set "$result"

View file

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