lib: initial commit, start of custom lib

This commit is contained in:
Charlie Root 2024-08-28 18:17:55 +02:00
commit f4373bac52
9 changed files with 102 additions and 71 deletions

View file

@ -1,16 +1,13 @@
{
description = "My NixOS config flake";
outputs = inputs:
inputs.flake-parts.lib.mkFlake {inherit inputs;} ({withSystem, ...}: {
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux"];
imports = [
./parts
./hosts
];
flake = {
nixosConfigurations = import ./hosts {inherit inputs withSystem;};
};
});
inputs = {
# what am I doing to this config help
flake-parts.url = "github:hercules-ci/flake-parts";
@ -58,6 +55,7 @@
emacs-overlay.url = "github:nix-community/emacs-overlay";
# I use schizofox as my personal browser. This is because I am schizophrenic.
schizofox = {
url = "github:schizofox/schizofox";
inputs = {

View file

@ -3,34 +3,35 @@
withSystem,
...
}: let
inherit (inputs) self;
# inherit (inputs) self;
inherit (inputs.nixpkgs) lib;
mkSystem = {
withSystem,
system,
...
} @ args:
withSystem system (
{
inputs',
self',
...
}:
lib.nixosSystem {
inherit system;
specialArgs =
lib.recursiveUpdate
{
inherit lib;
inherit inputs inputs';
inherit self self';
}
(args.specialArgs or {});
inherit (args) modules;
}
);
inherit (lib.builders) mkSystem;
# mkSystem = {
# withSystem,
# system,
# ...
# } @ args:
# withSystem system (
# {
# inputs',
# self',
# ...
# }:
# lib.nixosSystem {
# inherit system;
# specialArgs =
# lib.recursiveUpdate
# {
# inherit lib;
# inherit inputs inputs';
# inherit self self';
# }
# (args.specialArgs or {});
# inherit (args) modules;
# }
# );
in {
flake.nixosConfigurations = {
temperance = mkSystem {
inherit withSystem;
system = "x86_64-linux";
@ -48,4 +49,5 @@ in {
../modules
];
};
};
}

View file

@ -1,7 +1,8 @@
_: {
imports = [
# ./fmt.nix
./fmt.nix
./shell.nix
./templates
./lib
];
}

View file

@ -1,4 +1,5 @@
{
{inputs, ...}: {
imports = [inputs.treefmt-nix.flakeModule];
perSystem = {
config,
pkgs,
@ -15,7 +16,7 @@
programs = {
alejandra.enable = true;
shellcheck.enable = true; # cannot be configured, errors on basic bash convention
shellcheck.enable = true;
prettier = {
enable = true;

31
parts/lib/builders.nix Normal file
View file

@ -0,0 +1,31 @@
{
lib,
inputs,
self,
...
}: {
mkSystem = {
withSystem,
system,
...
} @ args:
withSystem system (
{
inputs',
self',
...
}:
lib.nixosSystem {
inherit system;
specialArgs =
lib.recursiveUpdate
{
inherit lib;
inherit inputs inputs';
inherit self self';
}
(args.specialArgs or {});
inherit (args) modules;
}
);
}

17
parts/lib/default.nix Normal file
View file

@ -0,0 +1,17 @@
{
inputs,
lib,
self,
...
}: let
callLibs = path: import path {inherit inputs lib self;};
sussyLib = inputs.nixpkgs.lib.extend (final: prev: {
builders = callLibs ./builders.nix;
});
in {
flake = {
lib = sussyLib;
# raf what the hell does this do you made me set it
_module.args.lib = sussyLib;
};
}

0
parts/lib/systemd.nix Normal file
View file

View file

@ -1,13 +0,0 @@
{
perSystem = _: {
pre-commit = {
settings = {
excludes = ["flake.lock"];
hooks = {
alejandra.enable = true;
prettier.enable = true;
};
};
};
};
}

View file

@ -9,9 +9,9 @@
DIRENV_LOG_FORMAT = "";
# inputsFrom = [config.treefmt.build.devShell];
inputsFrom = [config.treefmt.build.devShell];
packages = [
# config.treefmt.build.wrapper # treewide formatter
config.treefmt.build.wrapper # treewide formatter
pkgs.git # take a guess
(pkgs.writeShellApplication {
@ -20,12 +20,6 @@
nix flake update && git commit flake.lock -m "flake: bump inputs"
'';
})
(pkgs.writeShellApplication {
name = "rebuild";
text = ''
nh os switch
'';
})
];
};
};