refactor: add lib.my for useful functions

nixos
Moritz Böhme 2023-03-07 11:25:53 +01:00
parent 8e7a85b21a
commit 567e4eb551
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
2 changed files with 40 additions and 17 deletions

View File

@ -104,11 +104,17 @@
channelsConfig.allowUnfree = true; channelsConfig.allowUnfree = true;
lib = nixpkgs.lib.extend
(self: super: { my = import ./lib { lib = self; }; });
################ ################
### Overlays ### ### Overlays ###
################ ################
overlay = import ./overlays { inherit inputs; }; overlay = import ./overlays {
inherit inputs;
inherit (self) lib;
};
channels.nixpkgs.overlaysBuilder = channels: [ channels.nixpkgs.overlaysBuilder = channels: [
inputs.emacs.overlays.default inputs.emacs.overlays.default
@ -134,22 +140,23 @@
./modules/profiles/gaming.nix ./modules/profiles/gaming.nix
./modules/profiles/desktop.nix ./modules/profiles/desktop.nix
]; ];
hostDefaults = {
hostDefaults.modules = [ modules = [
./modules/default.nix ./modules/default.nix
self.nixosModules.base self.nixosModules.base
inputs.home-manager.nixosModule inputs.home-manager.nixosModule
{ {
home-manager = { home-manager = {
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
extraSpecialArgs = { inherit inputs self; }; extraSpecialArgs = { inherit inputs self; };
}; };
} }
inputs.hyprland.nixosModules.default inputs.hyprland.nixosModules.default
inputs.agenix.nixosModules.age inputs.agenix.nixosModules.age
inputs.howdy.nixosModules.default inputs.howdy.nixosModules.default
]; ];
};
hosts.nixos-laptop.modules = [ hosts.nixos-laptop.modules = [
./hosts/nixos-laptop ./hosts/nixos-laptop

16
lib/default.nix Normal file
View File

@ -0,0 +1,16 @@
{ lib, ... }:
lib.makeExtensible (self: rec {
mkDate = longDate: lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
];
mkVersionSrc = src: "unstable-" + builtins.substring 0 7 src.rev;
mkVersionInput = input:
let
date = mkDate (input.lastModifiedDate or "19700101");
rev = input.shortRev or "dirty";
in
"unstable-${date}_${rev}}";
})