1

reformat using alejandra

This commit is contained in:
2023-01-18 14:00:02 +01:00
parent 3ad68f24d6
commit eb44696de3
43 changed files with 1283 additions and 1095 deletions

View File

@ -1,6 +1,9 @@
{ inputs, pkgs, lib, ... }:
{
nixos = import ./nixos.nix { inherit inputs pkgs lib; };
modules = import ./modules.nix { inherit inputs pkgs lib; };
}
inputs,
pkgs,
lib,
...
}: {
nixos = import ./nixos.nix {inherit inputs pkgs lib;};
modules = import ./modules.nix {inherit inputs pkgs lib;};
}

View File

@ -1,25 +1,26 @@
{ inputs, pkgs, lib, ... }:
rec {
{
inputs,
pkgs,
lib,
...
}: rec {
# Conveniance wrapper for mkOption with boolean type
mkBoolOpt = def: desc:
lib.mkOption {
type = lib.types.bool;
default = def;
description = desc;
};
lib.mkOption {
type = lib.types.bool;
default = def;
description = desc;
};
# Alias for consistency
mkEnableOpt = lib.mkEnableOption;
# Like mkIf but the predicate is inverted
mkElse = pred: do:
(lib.mkIf (!pred) do);
mkElse = pred: do: (lib.mkIf (!pred) do);
# Creates a symlink if it doesn't exist
# If it exists renew the link
mkLink = src: dest:
''
mkLink = src: dest: ''
if [ -L "${dest}" ]; then
rm ${dest}
fi
@ -27,40 +28,43 @@ rec {
'';
# Removes a symlink if it exists
mkUnlink = dest:
''
mkUnlink = dest: ''
if [ -L "${dest}" ]; then
rm ${dest}
fi
'';
# TODO
mkMultiOptStr = { }:
{
mkMultiOptStr = {}: {
};
# TODO
mkMultiOptPkg = { }:
{
mkMultiOptPkg = {}: {
};
# Returns true if base contains element
contains = base: element:
lib.any (x: x == element) base;
lib.any (x: x == element) base;
# Returns base without occurences of elements that are also in remove
without = base: remove:
lib.filter (x: !(contains remove x)) base;
lib.filter (x: !(contains remove x)) base;
# For use with single element sets
attrName = set: let
names = lib.attrNames set;
in (if (names != [ ]) then (lib.head names) else null);
in (
if (names != [])
then (lib.head names)
else null
);
# For use with single element sets
attrValue = set: let
values = lib.attrValues set;
in (if (values != [ ]) then (lib.head values) else null);
in (
if (values != [])
then (lib.head values)
else null
);
}

View File

@ -1,47 +1,56 @@
{ inputs, pkgs, lib, ... }:
let
{
inputs,
pkgs,
lib,
...
}: let
inherit (inputs) home-manager;
in {
mkNixosConfig = { system ? "x86_64-linux", mylib, hostname, username ? "christoph", extraModules ? [ ] }:
lib.nixosSystem {
inherit system;
mkNixosConfig = {
system ? "x86_64-linux",
mylib,
hostname,
username ? "christoph",
extraModules ? [],
}:
lib.nixosSystem {
inherit system;
# Make our inputs available to the configuration.nix (for importing modules)
# specialArgs are propagated to all modules
specialArgs = { inherit inputs hostname username mylib; };
# Make our inputs available to the configuration.nix (for importing modules)
# specialArgs are propagated to all modules
specialArgs = {inherit inputs hostname username mylib;};
modules = builtins.concatLists [
[
# Replace the pkgs to include overlays/unfree
{ nixpkgs.pkgs = pkgs; }
modules = builtins.concatLists [
[
# Replace the pkgs to include overlays/unfree
{nixpkgs.pkgs = pkgs;}
# Main config file for all configs/hosts
../system
]
# Main config file for all configs/hosts
../system
]
extraModules
extraModules
# I included the home config statically like this as I am the only user
# I would have liked to make it more flexible (for multiple users on the same host)
# but I failed because nix stopped autoinjecting the required arguments and I didn't
# know how to handle that...
[
home-manager.nixosModules.home-manager {
# extraSpecialArgs are propagated to all hm config modules
home-manager.extraSpecialArgs = { inherit inputs hostname username mylib; };
# I included the home config statically like this as I am the only user
# I would have liked to make it more flexible (for multiple users on the same host)
# but I failed because nix stopped autoinjecting the required arguments and I didn't
# know how to handle that...
[
home-manager.nixosModules.home-manager
{
# extraSpecialArgs are propagated to all hm config modules
home-manager.extraSpecialArgs = {inherit inputs hostname username mylib;};
# Use systems pkgs, disables nixpkgs.* options in home.nix
home-manager.useGlobalPkgs = true;
# Use systems pkgs, disables nixpkgs.* options in home.nix
home-manager.useGlobalPkgs = true;
# Enable installing packages through users.christoph.packages to /etc/profiles instead of ~/.nix-profile
home-manager.useUserPackages = true;
# Enable installing packages through users.christoph.packages to /etc/profiles instead of ~/.nix-profile
home-manager.useUserPackages = true;
# User specific config file
home-manager.users.${username}.imports = [ ../home/${username} ];
}
]
];
};
# User specific config file
home-manager.users.${username}.imports = [../home/${username}];
}
]
];
};
}