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,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
'';
})
];
};
};