Apply nixpkgs-fmt
This commit is contained in:
parent
0f2c3b1f36
commit
7627395222
@ -1,5 +1,5 @@
|
|||||||
{ lib, pkgs, inputs, ... }:
|
{ lib, pkgs, inputs, ... }:
|
||||||
{
|
{
|
||||||
fileSystems = {
|
fileSystems = {
|
||||||
"/persist" = {
|
"/persist" = {
|
||||||
device = "/dev/disk/by-label/persist";
|
device = "/dev/disk/by-label/persist";
|
||||||
@ -8,7 +8,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {};
|
networking = { };
|
||||||
|
|
||||||
my = {
|
my = {
|
||||||
firewall = {
|
firewall = {
|
||||||
@ -26,4 +26,4 @@
|
|||||||
};
|
};
|
||||||
server.enable = true;
|
server.enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
16
flake.nix
16
flake.nix
@ -55,13 +55,18 @@
|
|||||||
lib = pkgsFlakes.unstable.lib;
|
lib = pkgsFlakes.unstable.lib;
|
||||||
|
|
||||||
pkgs' = mapAttrs (_: path: lib.my.mkPkgs path { overlays = [ libOverlay ]; }) pkgsFlakes;
|
pkgs' = mapAttrs (_: path: lib.my.mkPkgs path { overlays = [ libOverlay ]; }) pkgsFlakes;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
inherit lib;
|
inherit lib;
|
||||||
|
|
||||||
nixosModules = mapAttrs (_: path: let path' = ./. + "/modules/${path}"; in {
|
nixosModules = mapAttrs
|
||||||
|
(_: path:
|
||||||
|
let path' = ./. + "/modules/${path}"; in
|
||||||
|
{
|
||||||
_file = path';
|
_file = path';
|
||||||
imports = [ (import path') ];
|
imports = [ (import path') ];
|
||||||
}) {
|
})
|
||||||
|
{
|
||||||
common = "common.nix";
|
common = "common.nix";
|
||||||
build = "build.nix";
|
build = "build.nix";
|
||||||
dynamic-motd = "dynamic-motd.nix";
|
dynamic-motd = "dynamic-motd.nix";
|
||||||
@ -75,7 +80,7 @@
|
|||||||
vms = mapAttrs (_: system: system.config.my.build.devVM) self.nixosConfigurations;
|
vms = mapAttrs (_: system: system.config.my.build.devVM) self.nixosConfigurations;
|
||||||
|
|
||||||
apps =
|
apps =
|
||||||
let apps' = {}
|
let apps' = { }
|
||||||
// addPrefix "vms/" (mapAttrs (name: vm: { type = "app"; program = "${vm}/bin/run-${name}-vm"; }) self.vms);
|
// addPrefix "vms/" (mapAttrs (name: vm: { type = "app"; program = "${vm}/bin/run-${name}-vm"; }) self.vms);
|
||||||
in { x86_64-linux = apps'; };
|
in { x86_64-linux = apps'; };
|
||||||
|
|
||||||
@ -83,7 +88,8 @@
|
|||||||
let
|
let
|
||||||
pkgs = pkgs'.unstable.${system};
|
pkgs = pkgs'.unstable.${system};
|
||||||
flakePkg = f: f.defaultPackage.${system};
|
flakePkg = f: f.defaultPackage.${system};
|
||||||
in pkgs.mkShell {
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
packages = map flakePkg [
|
packages = map flakePkg [
|
||||||
agenix
|
agenix
|
||||||
deploy-rs
|
deploy-rs
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{ lib, extendModules, modulesPath, baseModules, options, config, ... }:
|
{ lib, extendModules, modulesPath, baseModules, options, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption;
|
inherit (lib) mkOption;
|
||||||
inherit (lib.my) mkBoolOpt;
|
inherit (lib.my) mkBoolOpt;
|
||||||
|
|
||||||
@ -15,13 +15,14 @@
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options.my = with lib.types; {
|
options.my = with lib.types; {
|
||||||
boot.isDevVM = mkBoolOpt false;
|
boot.isDevVM = mkBoolOpt false;
|
||||||
build = options.system.build;
|
build = options.system.build;
|
||||||
asDevVM = mkOption {
|
asDevVM = mkOption {
|
||||||
inherit (asDevVM) type;
|
inherit (asDevVM) type;
|
||||||
default = {};
|
default = { };
|
||||||
visible = "shallow";
|
visible = "shallow";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -29,4 +30,4 @@
|
|||||||
config.my.build = {
|
config.my.build = {
|
||||||
devVM = config.my.asDevVM.system.build.vm;
|
devVM = config.my.asDevVM.system.build.vm;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
{ lib, pkgs, inputs, system, config, options, ... }:
|
{ lib, pkgs, inputs, system, config, options, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf mkDefault mkAliasDefinitions;
|
inherit (lib) mkIf mkDefault mkAliasDefinitions;
|
||||||
inherit (lib.my) mkOpt;
|
inherit (lib.my) mkOpt;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options.my = with lib.types; {
|
options.my = with lib.types; {
|
||||||
user = mkOpt (attrsOf anything) {};
|
user = mkOpt (attrsOf anything) { };
|
||||||
};
|
};
|
||||||
|
|
||||||
config =
|
config =
|
||||||
let
|
let
|
||||||
defaultUsername = "dev";
|
defaultUsername = "dev";
|
||||||
uname = config.my.user.name;
|
uname = config.my.user.name;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
my = {
|
my = {
|
||||||
user = {
|
user = {
|
||||||
name = mkDefault defaultUsername;
|
name = mkDefault defaultUsername;
|
||||||
@ -90,4 +92,4 @@
|
|||||||
configurationRevision = with inputs; mkIf (self ? rev) self.rev;
|
configurationRevision = with inputs; mkIf (self ? rev) self.rev;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{ lib, pkgs, config, ... }:
|
{ lib, pkgs, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) optionalAttrs filterAttrs genAttrs mkIf mkDefault;
|
inherit (lib) optionalAttrs filterAttrs genAttrs mkIf mkDefault;
|
||||||
inherit (lib.my) mkOpt mkBoolOpt;
|
inherit (lib.my) mkOpt mkBoolOpt;
|
||||||
|
|
||||||
cfg = config.my.dynamic-motd;
|
cfg = config.my.dynamic-motd;
|
||||||
|
|
||||||
scriptBin = pkgs.writeShellScript "dynamic-motd-script" cfg.script;
|
scriptBin = pkgs.writeShellScript "dynamic-motd-script" cfg.script;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options.my.dynamic-motd = with lib.types; {
|
options.my.dynamic-motd = with lib.types; {
|
||||||
enable = mkBoolOpt true;
|
enable = mkBoolOpt true;
|
||||||
services = mkOpt (listOf str) [ "login" "ssh" ];
|
services = mkOpt (listOf str) [ "login" "ssh" ];
|
||||||
@ -21,4 +22,4 @@
|
|||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{ lib, options, config, ... }:
|
{ lib, options, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) optionalString concatStringsSep concatMapStringsSep optionalAttrs mkIf mkDefault mkMerge mkOverride;
|
inherit (lib) optionalString concatStringsSep concatMapStringsSep optionalAttrs mkIf mkDefault mkMerge mkOverride;
|
||||||
inherit (lib.my) parseIPPort mkOpt mkBoolOpt dummyOption;
|
inherit (lib.my) parseIPPort mkOpt mkBoolOpt dummyOption;
|
||||||
|
|
||||||
cfg = config.my.firewall;
|
cfg = config.my.firewall;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options.my.firewall = with lib.types; {
|
options.my.firewall = with lib.types; {
|
||||||
enable = mkBoolOpt true;
|
enable = mkBoolOpt true;
|
||||||
trustedInterfaces = options.networking.firewall.trustedInterfaces;
|
trustedInterfaces = options.networking.firewall.trustedInterfaces;
|
||||||
@ -12,7 +13,7 @@
|
|||||||
allowed = mkOpt (listOf (either port str)) [ "ssh" ];
|
allowed = mkOpt (listOf (either port str)) [ "ssh" ];
|
||||||
};
|
};
|
||||||
udp = {
|
udp = {
|
||||||
allowed = mkOpt (listOf (either port str)) [];
|
allowed = mkOpt (listOf (either port str)) [ ];
|
||||||
};
|
};
|
||||||
extraRules = mkOpt lines "";
|
extraRules = mkOpt lines "";
|
||||||
|
|
||||||
@ -111,7 +112,7 @@
|
|||||||
(mkIf cfg.nat.enable {
|
(mkIf cfg.nat.enable {
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = (cfg.nat.forwardPorts != []) -> (cfg.nat.externalInterface != null);
|
assertion = (cfg.nat.forwardPorts != [ ]) -> (cfg.nat.externalInterface != null);
|
||||||
message = "my.firewall.nat.forwardPorts requires my.firewall.nat.externalInterface";
|
message = "my.firewall.nat.forwardPorts requires my.firewall.nat.externalInterface";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@ -163,4 +164,4 @@
|
|||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
inherit (lib.my) mkBoolOpt;
|
inherit (lib.my) mkBoolOpt;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options.my.server.enable = mkBoolOpt false;
|
options.my.server.enable = mkBoolOpt false;
|
||||||
config = mkIf config.my.server.enable {
|
config = mkIf config.my.server.enable {
|
||||||
services.getty.autologinUser = config.my.user.name;
|
services.getty.autologinUser = config.my.user.name;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{ lib, pkgs, inputs, config, ... }:
|
{ lib, pkgs, inputs, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (builtins) elem;
|
inherit (builtins) elem;
|
||||||
inherit (lib) concatStringsSep concatMap concatMapStringsSep mkIf mkDefault mkMerge mkForce mkVMOverride;
|
inherit (lib) concatStringsSep concatMap concatMapStringsSep mkIf mkDefault mkMerge mkForce mkVMOverride;
|
||||||
inherit (lib.my) mkOpt mkBoolOpt mkVMOverride' dummyOption;
|
inherit (lib.my) mkOpt mkBoolOpt mkVMOverride' dummyOption;
|
||||||
@ -52,7 +52,8 @@
|
|||||||
fsType = "tmpfs";
|
fsType = "tmpfs";
|
||||||
options = [ "size=${cfg.size}" ];
|
options = [ "size=${cfg.size}" ];
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
imports = [ inputs.impermanence.nixosModule ];
|
imports = [ inputs.impermanence.nixosModule ];
|
||||||
|
|
||||||
options = with lib.types; {
|
options = with lib.types; {
|
||||||
@ -62,7 +63,7 @@
|
|||||||
size = mkOpt str "2G";
|
size = mkOpt str "2G";
|
||||||
unsaved = {
|
unsaved = {
|
||||||
showMotd = mkBoolOpt true;
|
showMotd = mkBoolOpt true;
|
||||||
ignore = mkOpt (listOf str) [];
|
ignore = mkOpt (listOf str) [ ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -202,4 +203,4 @@
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
17
systems.nix
17
systems.nix
@ -1,9 +1,10 @@
|
|||||||
{ lib, pkgsFlakes, inputs, modules }:
|
{ lib, pkgsFlakes, inputs, modules }:
|
||||||
let
|
let
|
||||||
inherit (builtins) attrValues mapAttrs;
|
inherit (builtins) attrValues mapAttrs;
|
||||||
inherit (lib) mkDefault;
|
inherit (lib) mkDefault;
|
||||||
|
|
||||||
mkSystem = name: {
|
mkSystem =
|
||||||
|
name: {
|
||||||
system,
|
system,
|
||||||
nixpkgs ? "unstable",
|
nixpkgs ? "unstable",
|
||||||
config,
|
config,
|
||||||
@ -15,21 +16,23 @@
|
|||||||
# vm build stuff that breaks our impl. REMOVE WHEN 22.05 IS OUT!
|
# vm build stuff that breaks our impl. REMOVE WHEN 22.05 IS OUT!
|
||||||
nixosSystem' = args:
|
nixosSystem' = args:
|
||||||
import "${pkgsFlake}/nixos/lib/eval-config.nix" (args // {
|
import "${pkgsFlake}/nixos/lib/eval-config.nix" (args // {
|
||||||
modules = args.modules ++ [ {
|
modules = args.modules ++ [{
|
||||||
system.nixos.versionSuffix =
|
system.nixos.versionSuffix =
|
||||||
".${lib.substring 0 8 pkgsFlake.lastModifiedDate}.${pkgsFlake.shortRev}";
|
".${lib.substring 0 8 pkgsFlake.lastModifiedDate}.${pkgsFlake.shortRev}";
|
||||||
system.nixos.revision = pkgsFlake.rev;
|
system.nixos.revision = pkgsFlake.rev;
|
||||||
} ];
|
}];
|
||||||
});
|
});
|
||||||
in nixosSystem' {
|
in
|
||||||
|
nixosSystem' {
|
||||||
inherit lib system;
|
inherit lib system;
|
||||||
specialArgs = { inherit inputs system; };
|
specialArgs = { inherit inputs system; };
|
||||||
modules = attrValues modules ++ [ { networking.hostName = mkDefault name; } config ];
|
modules = attrValues modules ++ [ { networking.hostName = mkDefault name; } config ];
|
||||||
};
|
};
|
||||||
in mapAttrs mkSystem {
|
in
|
||||||
|
mapAttrs mkSystem {
|
||||||
colony = {
|
colony = {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
nixpkgs = "stable";
|
nixpkgs = "stable";
|
||||||
config = boxes/colony.nix;
|
config = boxes/colony.nix;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
12
util.nix
12
util.nix
@ -1,9 +1,10 @@
|
|||||||
{ lib }:
|
{ lib }:
|
||||||
let
|
let
|
||||||
inherit (builtins) replaceStrings elemAt;
|
inherit (builtins) replaceStrings elemAt;
|
||||||
inherit (lib) genAttrs mapAttrs' types mkOption mkOverride;
|
inherit (lib) genAttrs mapAttrs' types mkOption mkOverride;
|
||||||
inherit (lib.flake) defaultSystems;
|
inherit (lib.flake) defaultSystems;
|
||||||
in rec {
|
in
|
||||||
|
rec {
|
||||||
addPrefix = prefix: mapAttrs' (n: v: { name = "${prefix}${n}"; value = v; });
|
addPrefix = prefix: mapAttrs' (n: v: { name = "${prefix}${n}"; value = v; });
|
||||||
# Yoinked from nixpkgs/nixos/modules/services/networking/nat.nix
|
# Yoinked from nixpkgs/nixos/modules/services/networking/nat.nix
|
||||||
isIPv6 = ip: builtins.length (lib.splitString ":" ip) > 2;
|
isIPv6 = ip: builtins.length (lib.splitString ":" ip) > 2;
|
||||||
@ -13,7 +14,8 @@
|
|||||||
matchIP = if v6 then "[[]([0-9a-fA-F:]+)[]]" else "([0-9.]+)";
|
matchIP = if v6 then "[[]([0-9a-fA-F:]+)[]]" else "([0-9.]+)";
|
||||||
m = builtins.match "${matchIP}:([0-9-]+)" ipp;
|
m = builtins.match "${matchIP}:([0-9-]+)" ipp;
|
||||||
checked = v: if m == null then throw "bad ip:ports `${ipp}'" else v;
|
checked = v: if m == null then throw "bad ip:ports `${ipp}'" else v;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
inherit v6;
|
inherit v6;
|
||||||
ip = checked (elemAt m 0);
|
ip = checked (elemAt m 0);
|
||||||
ports = checked (replaceStrings ["-"] [":"] (elemAt m 1));
|
ports = checked (replaceStrings ["-"] [":"] (elemAt m 1));
|
||||||
@ -28,5 +30,5 @@
|
|||||||
example = true;
|
example = true;
|
||||||
};
|
};
|
||||||
mkVMOverride' = mkOverride 9;
|
mkVMOverride' = mkOverride 9;
|
||||||
dummyOption = mkOption {};
|
dummyOption = mkOption { };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user