Compare commits

..

No commits in common. "591dd87752cfcb42c56c3663b004c4784a4c1d9d" and "dfb02038ac05dacda0b3cc2224d349135df7972a" have entirely different histories.

3 changed files with 112 additions and 40 deletions

View file

@ -1,8 +1,8 @@
{ inputs ? import ./npins let
, system ? builtins.currentSystem inputs = import ./npins;
, pkgs ? import inputs.nixpkgs { config = { }; overlays = [ ]; inherit system; } system = "x86_64-linux";
, lib ? import "${inputs.nixpkgs}/lib" pkgs = import inputs.nixpkgs { config = { }; overlays = [ ]; system = builtins.currentSystem; };
// { 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,9 +17,7 @@
} }
// builtins.removeAttrs args [ "modules" ] // builtins.removeAttrs args [ "modules" ]
); );
} in
,
}:
rec { rec {
nixosModules = { nixosModules = {
disko = "${inputs.disko}/module.nix"; disko = "${inputs.disko}/module.nix";
@ -33,7 +31,7 @@ rec {
# test with # test with
# nix-build -A nixosConfigurations.<config>.installTest # nix-build -A nixosConfigurations.<config>.installTest
nixosConfigurations = { nixosConfigurations = {
mastodon = lib.nixosSystem { mastodon = nixosSystem {
inherit system; inherit system;
modules = with nixosModules; [ modules = with nixosModules; [
disko disko
@ -43,7 +41,7 @@ rec {
]; ];
}; };
peertube = lib.nixosSystem { peertube = nixosSystem {
inherit system; inherit system;
modules = with nixosModules; [ modules = with nixosModules; [
disko disko
@ -53,7 +51,7 @@ rec {
]; ];
}; };
pixelfed = lib.nixosSystem { pixelfed = nixosSystem {
inherit system; inherit system;
modules = with nixosModules; [ modules = with nixosModules; [
disko disko
@ -63,7 +61,7 @@ rec {
]; ];
}; };
all = lib.nixosSystem { all = 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 ${./.} -A nixosConfigurations.${name} --eval-store auto --store ssh-ng://${name})" result="$(nix build ${./.}#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,25 +6,99 @@
disko.url = "github:nix-community/disko"; disko.url = "github:nix-community/disko";
}; };
outputs = inputs@{ self, nixpkgs, disko, ... }: outputs = { self, nixpkgs, disko, ... }:
let let
system = "x86_64-linux"; system = "x86_64-linux";
default = import ./default.nix { inherit system inputs; }; pkgs = nixpkgs.legacyPackages.${system};
in { in {
inherit (default) nixosModules = {
nixosModules
nixosConfigurations ## 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
];
};
};
# 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} = default.tests; checks.${system} = {
mastodon-garage = import ./tests/mastodon-garage.nix { inherit pkgs; };
pixelfed-garage = import ./tests/pixelfed-garage.nix { inherit pkgs; };
};
devShells.${system}.default = default.shell; devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
nil
];
};
}; };
} }