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,25 +1,23 @@
{ 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"
(
{
inherit lib;
# Allow system to be set modularly in nixpkgs.system.
# We set it to null, to remove the "legacy" entrypoint's
# non-hermetic default.
system = null;
let
inputs = import ./npins;
system = "x86_64-linux";
pkgs = import inputs.nixpkgs { config = { }; overlays = [ ]; system = builtins.currentSystem; };
lib = import "${inputs.nixpkgs}/lib" // { inherit nixosSystem; };
nixosSystem = args:
import "${inputs.nixpkgs}/nixos/lib/eval-config.nix"
(
{
inherit lib;
# Allow system to be set modularly in nixpkgs.system.
# We set it to null, to remove the "legacy" entrypoint's
# non-hermetic default.
system = null;
modules = args.modules;
}
// builtins.removeAttrs args [ "modules" ]
);
}
,
}:
modules = args.modules;
}
// builtins.removeAttrs args [ "modules" ]
);
in
rec {
nixosModules = {
disko = "${inputs.disko}/module.nix";
@ -33,7 +31,7 @@ rec {
# test with
# nix-build -A nixosConfigurations.<config>.installTest
nixosConfigurations = {
mastodon = lib.nixosSystem {
mastodon = nixosSystem {
inherit system;
modules = with nixosModules; [
disko
@ -43,7 +41,7 @@ rec {
];
};
peertube = lib.nixosSystem {
peertube = nixosSystem {
inherit system;
modules = with nixosModules; [
disko
@ -53,7 +51,7 @@ rec {
];
};
pixelfed = lib.nixosSystem {
pixelfed = nixosSystem {
inherit system;
modules = with nixosModules; [
disko
@ -63,7 +61,7 @@ rec {
];
};
all = lib.nixosSystem {
all = nixosSystem {
inherit system;
modules = with nixosModules; [
interactive-vm

View file

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

102
flake.nix
View file

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