Apply nixpkgs-fmt

This commit is contained in:
Jack O'Sullivan 2022-02-13 13:10:21 +00:00
parent 0f2c3b1f36
commit 7627395222
10 changed files with 603 additions and 585 deletions

View File

@ -1,5 +1,5 @@
{ lib, pkgs, inputs, ... }:
{
{
fileSystems = {
"/persist" = {
device = "/dev/disk/by-label/persist";
@ -8,7 +8,7 @@
};
};
networking = {};
networking = { };
my = {
firewall = {
@ -26,4 +26,4 @@
};
server.enable = true;
};
}
}

View File

@ -55,13 +55,18 @@
lib = pkgsFlakes.unstable.lib;
pkgs' = mapAttrs (_: path: lib.my.mkPkgs path { overlays = [ libOverlay ]; }) pkgsFlakes;
in {
in
{
inherit lib;
nixosModules = mapAttrs (_: path: let path' = ./. + "/modules/${path}"; in {
nixosModules = mapAttrs
(_: path:
let path' = ./. + "/modules/${path}"; in
{
_file = path';
imports = [ (import path') ];
}) {
})
{
common = "common.nix";
build = "build.nix";
dynamic-motd = "dynamic-motd.nix";
@ -75,7 +80,7 @@
vms = mapAttrs (_: system: system.config.my.build.devVM) self.nixosConfigurations;
apps =
let apps' = {}
let apps' = { }
// addPrefix "vms/" (mapAttrs (name: vm: { type = "app"; program = "${vm}/bin/run-${name}-vm"; }) self.vms);
in { x86_64-linux = apps'; };
@ -83,7 +88,8 @@
let
pkgs = pkgs'.unstable.${system};
flakePkg = f: f.defaultPackage.${system};
in pkgs.mkShell {
in
pkgs.mkShell {
packages = map flakePkg [
agenix
deploy-rs

View File

@ -1,5 +1,5 @@
{ lib, extendModules, modulesPath, baseModules, options, config, ... }:
let
let
inherit (lib) mkOption;
inherit (lib.my) mkBoolOpt;
@ -15,13 +15,14 @@
})
];
};
in {
in
{
options.my = with lib.types; {
boot.isDevVM = mkBoolOpt false;
build = options.system.build;
asDevVM = mkOption {
inherit (asDevVM) type;
default = {};
default = { };
visible = "shallow";
};
};
@ -29,4 +30,4 @@
config.my.build = {
devVM = config.my.asDevVM.system.build.vm;
};
}
}

View File

@ -1,17 +1,19 @@
{ lib, pkgs, inputs, system, config, options, ... }:
let
let
inherit (lib) mkIf mkDefault mkAliasDefinitions;
inherit (lib.my) mkOpt;
in {
in
{
options.my = with lib.types; {
user = mkOpt (attrsOf anything) {};
user = mkOpt (attrsOf anything) { };
};
config =
let
defaultUsername = "dev";
uname = config.my.user.name;
in {
in
{
my = {
user = {
name = mkDefault defaultUsername;
@ -90,4 +92,4 @@
configurationRevision = with inputs; mkIf (self ? rev) self.rev;
};
};
}
}

View File

@ -1,12 +1,13 @@
{ lib, pkgs, config, ... }:
let
let
inherit (lib) optionalAttrs filterAttrs genAttrs mkIf mkDefault;
inherit (lib.my) mkOpt mkBoolOpt;
cfg = config.my.dynamic-motd;
scriptBin = pkgs.writeShellScript "dynamic-motd-script" cfg.script;
in {
in
{
options.my.dynamic-motd = with lib.types; {
enable = mkBoolOpt true;
services = mkOpt (listOf str) [ "login" "ssh" ];
@ -21,4 +22,4 @@
'';
});
};
}
}

View File

@ -1,10 +1,11 @@
{ lib, options, config, ... }:
let
let
inherit (lib) optionalString concatStringsSep concatMapStringsSep optionalAttrs mkIf mkDefault mkMerge mkOverride;
inherit (lib.my) parseIPPort mkOpt mkBoolOpt dummyOption;
cfg = config.my.firewall;
in {
in
{
options.my.firewall = with lib.types; {
enable = mkBoolOpt true;
trustedInterfaces = options.networking.firewall.trustedInterfaces;
@ -12,7 +13,7 @@
allowed = mkOpt (listOf (either port str)) [ "ssh" ];
};
udp = {
allowed = mkOpt (listOf (either port str)) [];
allowed = mkOpt (listOf (either port str)) [ ];
};
extraRules = mkOpt lines "";
@ -111,7 +112,7 @@
(mkIf cfg.nat.enable {
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";
}
];
@ -163,4 +164,4 @@
'';
})
]);
}
}

View File

@ -1,10 +1,11 @@
{ config, lib, ... }:
let
let
inherit (lib) mkIf;
inherit (lib.my) mkBoolOpt;
in {
in
{
options.my.server.enable = mkBoolOpt false;
config = mkIf config.my.server.enable {
services.getty.autologinUser = config.my.user.name;
};
}
}

View File

@ -1,5 +1,5 @@
{ lib, pkgs, inputs, config, ... }:
let
let
inherit (builtins) elem;
inherit (lib) concatStringsSep concatMap concatMapStringsSep mkIf mkDefault mkMerge mkForce mkVMOverride;
inherit (lib.my) mkOpt mkBoolOpt mkVMOverride' dummyOption;
@ -52,7 +52,8 @@
fsType = "tmpfs";
options = [ "size=${cfg.size}" ];
};
in {
in
{
imports = [ inputs.impermanence.nixosModule ];
options = with lib.types; {
@ -62,7 +63,7 @@
size = mkOpt str "2G";
unsaved = {
showMotd = mkBoolOpt true;
ignore = mkOpt (listOf str) [];
ignore = mkOpt (listOf str) [ ];
};
};
@ -202,4 +203,4 @@
};
})
]);
}
}

View File

@ -1,9 +1,10 @@
{ lib, pkgsFlakes, inputs, modules }:
let
let
inherit (builtins) attrValues mapAttrs;
inherit (lib) mkDefault;
mkSystem = name: {
mkSystem =
name: {
system,
nixpkgs ? "unstable",
config,
@ -15,21 +16,23 @@
# vm build stuff that breaks our impl. REMOVE WHEN 22.05 IS OUT!
nixosSystem' = args:
import "${pkgsFlake}/nixos/lib/eval-config.nix" (args // {
modules = args.modules ++ [ {
modules = args.modules ++ [{
system.nixos.versionSuffix =
".${lib.substring 0 8 pkgsFlake.lastModifiedDate}.${pkgsFlake.shortRev}";
system.nixos.revision = pkgsFlake.rev;
} ];
}];
});
in nixosSystem' {
in
nixosSystem' {
inherit lib system;
specialArgs = { inherit inputs system; };
modules = attrValues modules ++ [ { networking.hostName = mkDefault name; } config ];
};
in mapAttrs mkSystem {
in
mapAttrs mkSystem {
colony = {
system = "x86_64-linux";
nixpkgs = "stable";
config = boxes/colony.nix;
};
}
}

View File

@ -1,9 +1,10 @@
{ lib }:
let
let
inherit (builtins) replaceStrings elemAt;
inherit (lib) genAttrs mapAttrs' types mkOption mkOverride;
inherit (lib.flake) defaultSystems;
in rec {
in
rec {
addPrefix = prefix: mapAttrs' (n: v: { name = "${prefix}${n}"; value = v; });
# Yoinked from nixpkgs/nixos/modules/services/networking/nat.nix
isIPv6 = ip: builtins.length (lib.splitString ":" ip) > 2;
@ -13,7 +14,8 @@
matchIP = if v6 then "[[]([0-9a-fA-F:]+)[]]" else "([0-9.]+)";
m = builtins.match "${matchIP}:([0-9-]+)" ipp;
checked = v: if m == null then throw "bad ip:ports `${ipp}'" else v;
in {
in
{
inherit v6;
ip = checked (elemAt m 0);
ports = checked (replaceStrings ["-"] [":"] (elemAt m 1));
@ -28,5 +30,5 @@
example = true;
};
mkVMOverride' = mkOverride 9;
dummyOption = mkOption {};
}
dummyOption = mkOption { };
}