🎨 nixpkgs-fmt

This commit is contained in:
James Walker 2022-05-06 20:01:04 -04:00
parent be14e0698c
commit ea5ba53e3c
Signed by: walkah
GPG Key ID: 3C127179D6086E93
9 changed files with 187 additions and 164 deletions

View File

@ -14,9 +14,18 @@
}; };
}; };
outputs = { self, nixpkgs, deploy-rs, flake-utils, home-manager, dotfiles, ... }@attrs: outputs =
{ self
, nixpkgs
, deploy-rs
, flake-utils
, home-manager
, dotfiles
, ...
}@attrs:
let let
mkSystem = hostName: system: modules: mkSystem = hostName: system: modules:
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
system = system; system = system;
modules = [ modules = [
@ -26,14 +35,12 @@
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
}) })
] ] ++ modules;
++ modules;
}; };
in in
flake-utils.lib.eachDefaultSystem flake-utils.lib.eachDefaultSystem
(system: (system:
let let pkgs = nixpkgs.legacyPackages.${system};
pkgs = nixpkgs.legacyPackages.${system};
in in
{ {
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
@ -42,13 +49,19 @@
}) // { }) // {
nixosConfigurations = { nixosConfigurations = {
# Aristotle # Aristotle
agent = mkSystem "agent" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ]; agent = mkSystem "agent" "aarch64-linux"
form = mkSystem "form" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ]; [ ./hosts/aristotle/configuration.nix ];
matter = mkSystem "matter" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ]; form = mkSystem "form" "aarch64-linux"
purpose = mkSystem "purpose" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ]; [ ./hosts/aristotle/configuration.nix ];
matter = mkSystem "matter" "aarch64-linux"
[ ./hosts/aristotle/configuration.nix ];
purpose = mkSystem "purpose" "aarch64-linux"
[ ./hosts/aristotle/configuration.nix ];
plato = mkSystem "plato" "x86_64-linux" [ ./hosts/plato/configuration.nix ]; plato =
socrates = mkSystem "socrates" "x86_64-linux" [ ./hosts/socrates/configuration.nix ]; mkSystem "plato" "x86_64-linux" [ ./hosts/plato/configuration.nix ];
socrates = mkSystem "socrates" "x86_64-linux"
[ ./hosts/socrates/configuration.nix ];
}; };
deploy.nodes = { deploy.nodes = {

View File

@ -2,7 +2,8 @@
with lib; with lib;
let cfg = config.walkah.coredns; let cfg = config.walkah.coredns;
in { in
{
options.walkah.coredns = { options.walkah.coredns = {
enable = mkEnableOption ""; enable = mkEnableOption "";
addr = mkOption { addr = mkOption {

View File

@ -1,7 +1,8 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let cfg = config.services.gitea; let cfg = config.services.gitea;
in { in
{
users.users.git = { users.users.git = {
description = "Gitea Service"; description = "Gitea Service";
home = cfg.stateDir; home = cfg.stateDir;

View File

@ -22,7 +22,8 @@ let
} }
]; ];
in { in
{
imports = [ ./default.nix ]; imports = [ ./default.nix ];
environment.systemPackages = with pkgs; [ ipfs-migrator ]; environment.systemPackages = with pkgs; [ ipfs-migrator ];

View File

@ -15,16 +15,19 @@
enableACME = true; enableACME = true;
locations."= /.well-known/matrix/server".extraConfig = locations."= /.well-known/matrix/server".extraConfig =
let server = { "m.server" = "matrix.walkah.chat:443"; }; let server = { "m.server" = "matrix.walkah.chat:443"; };
in '' in
''
default_type application/json; default_type application/json;
add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON server}'; return 200 '${builtins.toJSON server}';
''; '';
locations."= /.well-known/matrix/client".extraConfig = let locations."= /.well-known/matrix/client".extraConfig =
let
client = { client = {
"m.homeserver" = { "base_url" = "https://matrix.walkah.chat"; }; "m.homeserver" = { "base_url" = "https://matrix.walkah.chat"; };
}; };
in '' in
''
default_type application/json; default_type application/json;
add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON client}'; return 200 '${builtins.toJSON client}';

View File

@ -34,7 +34,7 @@ let
submodules = if spec ? submodules then spec.submodules else false; submodules = if spec ? submodules then spec.submodules else false;
in in
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; } builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }
// (if builtins.compareVersions builtins.nixVersion "2.4" >= 0 then { inherit submodules; } else {}); // (if builtins.compareVersions builtins.nixVersion "2.4" >= 0 then { inherit submodules; } else { });
fetch_local = spec: spec.path; fetch_local = spec: spec.path;
@ -71,7 +71,7 @@ let
if builtins.hasAttr "nixpkgs" sources if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {} import <nixpkgs> { }
else else
abort abort
'' ''
@ -114,7 +114,7 @@ let
); );
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
@ -125,7 +125,7 @@ let
concatStrings = builtins.concatStringsSep ""; concatStrings = builtins.concatStringsSep "";
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
optionalAttrs = cond: as: if cond then as else {}; optionalAttrs = cond: as: if cond then as else { };
# fetchTarball version that is compatible between all the versions of Nix # fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, name ? null, sha256 }@attrs: builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
@ -149,19 +149,22 @@ let
# Create the final "sources" from the config # Create the final "sources" from the config
mkSources = config: mkSources = config:
mapAttrs ( mapAttrs
(
name: spec: name: spec:
if builtins.hasAttr "outPath" spec if builtins.hasAttr "outPath" spec
then abort then
abort
"The values in sources.json should not have an 'outPath' attribute" "The values in sources.json should not have an 'outPath' attribute"
else else
spec // { outPath = replace name (fetch config.pkgs name spec); } spec // { outPath = replace name (fetch config.pkgs name spec); }
) config.sources; )
config.sources;
# The "config" used by the fetchers # The "config" used by the fetchers
mkConfig = mkConfig =
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) , sources ? if isNull sourcesFile then { } else builtins.fromJSON (builtins.readFile sourcesFile)
, system ? builtins.currentSystem , system ? builtins.currentSystem
, pkgs ? mkPkgs sources system , pkgs ? mkPkgs sources system
}: rec { }: rec {
@ -173,4 +176,4 @@ let
}; };
in in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); }

View File

@ -10,7 +10,8 @@ let
(optionalString (cfg.initPeers != [ ]) "--peers") (optionalString (cfg.initPeers != [ ]) "--peers")
(lib.strings.concatStringsSep "," cfg.initPeers) (lib.strings.concatStringsSep "," cfg.initPeers)
]; ];
in { in
{
###### interface ###### interface