🎨 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
mkSystem = hostName: system: modules:
nixpkgs.lib.nixosSystem {
system = system;
modules = [
@ -26,29 +35,33 @@
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
})
]
++ modules;
] ++ modules;
};
in
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells.default = pkgs.mkShell {
buildInputs = [ deploy-rs.packages.${system}.deploy-rs pkgs.sops ];
};
}) // {
let pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells.default = pkgs.mkShell {
buildInputs = [ deploy-rs.packages.${system}.deploy-rs pkgs.sops ];
};
}) // {
nixosConfigurations = {
# Aristotle
agent = mkSystem "agent" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ];
form = mkSystem "form" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ];
matter = mkSystem "matter" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ];
purpose = mkSystem "purpose" "aarch64-linux" [ ./hosts/aristotle/configuration.nix ];
agent = mkSystem "agent" "aarch64-linux"
[ ./hosts/aristotle/configuration.nix ];
form = mkSystem "form" "aarch64-linux"
[ ./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 ];
socrates = mkSystem "socrates" "x86_64-linux" [ ./hosts/socrates/configuration.nix ];
plato =
mkSystem "plato" "x86_64-linux" [ ./hosts/plato/configuration.nix ];
socrates = mkSystem "socrates" "x86_64-linux"
[ ./hosts/socrates/configuration.nix ];
};
deploy.nodes = {

View File

@ -16,91 +16,91 @@
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target-path = "/";
__overlay__ {
fan0: rpi-poe-fan@0 {
compatible = "raspberrypi,rpi-poe-fan";
firmware = <&firmware>;
cooling-min-state = <0>;
cooling-max-state = <4>;
#cooling-cells = <2>;
cooling-levels = <0 1 10 100 255>;
status = "okay";
};
};
};
fragment@0 {
target-path = "/";
__overlay__ {
fan0: rpi-poe-fan@0 {
compatible = "raspberrypi,rpi-poe-fan";
firmware = <&firmware>;
cooling-min-state = <0>;
cooling-max-state = <4>;
#cooling-cells = <2>;
cooling-levels = <0 1 10 100 255>;
status = "okay";
};
};
};
fragment@1 {
target = <&cpu_thermal>;
__overlay__ {
trips {
trip0: trip0 {
temperature = <40000>;
hysteresis = <2000>;
type = "active";
};
trip1: trip1 {
temperature = <45000>;
hysteresis = <2000>;
type = "active";
};
trip2: trip2 {
temperature = <50000>;
hysteresis = <2000>;
type = "active";
};
trip3: trip3 {
temperature = <55000>;
hysteresis = <5000>;
type = "active";
};
};
cooling-maps {
map0 {
trip = <&trip0>;
cooling-device = <&fan0 0 1>;
};
map1 {
trip = <&trip1>;
cooling-device = <&fan0 1 2>;
};
map2 {
trip = <&trip2>;
cooling-device = <&fan0 2 3>;
};
map3 {
trip = <&trip3>;
cooling-device = <&fan0 3 4>;
};
};
};
};
fragment@1 {
target = <&cpu_thermal>;
__overlay__ {
trips {
trip0: trip0 {
temperature = <40000>;
hysteresis = <2000>;
type = "active";
};
trip1: trip1 {
temperature = <45000>;
hysteresis = <2000>;
type = "active";
};
trip2: trip2 {
temperature = <50000>;
hysteresis = <2000>;
type = "active";
};
trip3: trip3 {
temperature = <55000>;
hysteresis = <5000>;
type = "active";
};
};
cooling-maps {
map0 {
trip = <&trip0>;
cooling-device = <&fan0 0 1>;
};
map1 {
trip = <&trip1>;
cooling-device = <&fan0 1 2>;
};
map2 {
trip = <&trip2>;
cooling-device = <&fan0 2 3>;
};
map3 {
trip = <&trip3>;
cooling-device = <&fan0 3 4>;
};
};
};
};
fragment@2 {
target-path = "/__overrides__";
__overlay__ {
poe_fan_temp0 = <&trip0>,"temperature:0";
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
poe_fan_temp1 = <&trip1>,"temperature:0";
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
poe_fan_temp2 = <&trip2>,"temperature:0";
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
poe_fan_temp3 = <&trip3>,"temperature:0";
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
};
};
fragment@2 {
target-path = "/__overrides__";
__overlay__ {
poe_fan_temp0 = <&trip0>,"temperature:0";
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
poe_fan_temp1 = <&trip1>,"temperature:0";
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
poe_fan_temp2 = <&trip2>,"temperature:0";
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
poe_fan_temp3 = <&trip3>,"temperature:0";
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
};
};
__overrides__ {
poe_fan_temp0 = <&trip0>,"temperature:0";
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
poe_fan_temp1 = <&trip1>,"temperature:0";
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
poe_fan_temp2 = <&trip2>,"temperature:0";
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
poe_fan_temp3 = <&trip3>,"temperature:0";
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
};
__overrides__ {
poe_fan_temp0 = <&trip0>,"temperature:0";
poe_fan_temp0_hyst = <&trip0>,"hysteresis:0";
poe_fan_temp1 = <&trip1>,"temperature:0";
poe_fan_temp1_hyst = <&trip1>,"hysteresis:0";
poe_fan_temp2 = <&trip2>,"temperature:0";
poe_fan_temp2_hyst = <&trip2>,"hysteresis:0";
poe_fan_temp3 = <&trip3>,"temperature:0";
poe_fan_temp3_hyst = <&trip3>,"hysteresis:0";
};
};
'';
}];

View File

@ -42,4 +42,4 @@
Xcode = 497799835;
};
};
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -10,31 +10,31 @@ let
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
fetch_tarball = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
fetch_git = name: spec:
let
ref =
if spec ? ref then spec.ref else
if spec ? branch then "refs/heads/${spec.branch}" else
if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
if spec ? branch then "refs/heads/${spec.branch}" else
if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
submodules = if spec ? submodules then spec.submodules else false;
in
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }
// (if builtins.compareVersions builtins.nixVersion "2.4" >= 0 then { inherit submodules; } else {});
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }
// (if builtins.compareVersions builtins.nixVersion "2.4" >= 0 then { inherit submodules; } else { });
fetch_local = spec: spec.path;
@ -68,16 +68,16 @@ let
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {}
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> { }
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
# The actual fetching function.
fetch = pkgs: name: spec:
@ -100,10 +100,10 @@ let
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in
if ersatz == "" then drv else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
if ersatz == "" then drv else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
# Ports of functions for older nix versions
@ -114,7 +114,7 @@ let
);
# 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
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
@ -125,43 +125,46 @@ let
concatStrings = builtins.concatStringsSep "";
# 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
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchTarball attrs;
if lessThan nixVersion "1.12" then
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchurl attrs;
if lessThan nixVersion "1.12" then
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchurl attrs;
# Create the final "sources" from the config
mkSources = config:
mapAttrs (
name: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = replace name (fetch config.pkgs name spec); }
) config.sources;
mapAttrs
(
name: spec:
if builtins.hasAttr "outPath" spec
then
abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = replace name (fetch config.pkgs name spec); }
)
config.sources;
# The "config" used by the fetchers
mkConfig =
{ 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
, pkgs ? mkPkgs sources system
}: rec {
@ -173,4 +176,4 @@ let
};
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")
(lib.strings.concatStringsSep "," cfg.initPeers)
];
in {
in
{
###### interface
@ -97,9 +98,9 @@ in {
RemainAfterExit = true;
User = cfg.user;
Group = cfg.group;
} // optionalAttrs (cfg.secretFile != null) {
EnvironmentFile = cfg.secretFile;
};
} // optionalAttrs (cfg.secretFile != null) {
EnvironmentFile = cfg.secretFile;
};
unitConfig.ConditionDirectoryNotEmpty = "!${cfg.dataDir}";
};