about summary refs log tree commit diff
diff options
context:
space:
mode:
authorazahi <azat@bahawi.net>2024-10-22 14:14:46 +0300
committerazahi <azat@bahawi.net>2024-10-22 14:14:46 +0300
commit54db8efe14f4d83d2a191df62c251508dcf8be70 (patch)
tree5e491674a19dfc7723181ef25cc66d3d1718411f
parent2024-10-22 (diff)
2024-10-22
Diffstat (limited to '')
-rw-r--r--flake.lock17
-rw-r--r--flake.nix5
-rw-r--r--lib/default.nix30
-rw-r--r--overlays.nix243
4 files changed, 155 insertions, 140 deletions
diff --git a/flake.lock b/flake.lock
index ed48601..5ca3cec 100644
--- a/flake.lock
+++ b/flake.lock
@@ -470,6 +470,22 @@
         "type": "github"
       }
     },
+    "infuse": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1725534720,
+        "narHash": "sha256-nUKvPYUVKPGwqCSy4S46FpuaZP1oyodIh2THE+Hu+HU=",
+        "ref": "refs/heads/trunk",
+        "rev": "b5167b3ec5a398ab0b5377c07138d4e6a393a57d",
+        "revCount": 31,
+        "type": "git",
+        "url": "https://codeberg.org/amjoseph/infuse.nix"
+      },
+      "original": {
+        "type": "git",
+        "url": "https://codeberg.org/amjoseph/infuse.nix"
+      }
+    },
     "mailserver": {
       "inputs": {
         "blobs": "blobs",
@@ -708,6 +724,7 @@
         "home-manager": "home-manager",
         "homelab-svg-assets": "homelab-svg-assets",
         "impermanence": "impermanence",
+        "infuse": "infuse",
         "mailserver": "mailserver",
         "minecraft": "minecraft",
         "nix-index-database": "nix-index-database",
diff --git a/flake.nix b/flake.nix
index 68fa8bb..ec432c3 100644
--- a/flake.nix
+++ b/flake.nix
@@ -57,6 +57,11 @@
     #   };
     # };
 
+    infuse = {
+      url = "git+https://codeberg.org/amjoseph/infuse.nix";
+      flake = false;
+    };
+
     dns = {
       url = "github:nix-community/dns.nix";
       inputs = {
diff --git a/lib/default.nix b/lib/default.nix
index 662938e..3a67063 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -4,7 +4,6 @@
   system,
   ...
 }:
-with lib;
 rec {
   my = import ./my.nix { inherit lib inputs system; };
 
@@ -12,6 +11,10 @@ rec {
 
   packages = import ./packages.nix { inherit lib inputs system; };
 
+  infuse = import inputs.infuse {
+    inherit lib;
+  };
+
   isEven =
     number:
     assert (builtins.isInt number) || (builtins.isFloat number);
@@ -28,7 +31,7 @@ rec {
   mkTcpMem =
     min: ini: max:
     assert min <= ini && ini <= max;
-    concatMapStrings (x: toString x + " ") (
+    lib.concatMapStrings (x: toString x + " ") (
       map (pow 2) [
         min
         ini
@@ -49,22 +52,22 @@ rec {
   #
   modulesIn =
     dir:
-    pipe dir [
+    lib.pipe dir [
       builtins.readDir
-      (mapAttrsToList (
+      (lib.mapAttrsToList (
         name: type:
         let
           modulePath = dir + "/${name}";
         in
-        if type == "regular" && hasSuffix ".nix" name && name != "default.nix" then
-          [ (nameValuePair (removeSuffix ".nix" name) modulePath) ]
-        else if type == "directory" && pathExists (modulePath + "/default.nix") then
-          [ (nameValuePair name modulePath) ]
+        if type == "regular" && lib.hasSuffix ".nix" name && name != "default.nix" then
+          [ (lib.nameValuePair (lib.removeSuffix ".nix" name) modulePath) ]
+        else if type == "directory" && lib.pathExists (modulePath + "/default.nix") then
+          [ (lib.nameValuePair name modulePath) ]
         else
           [ ]
       ))
-      concatLists
-      listToAttrs
+      lib.concatLists
+      lib.listToAttrs
     ];
 
   # Override a module using another Nixpkgs source tree.
@@ -99,9 +102,9 @@ rec {
           src = inputs.nixpkgs.legacyPackages.${system}.fetchzip {
             url =
               let
-                cons = splitString ":" ref;
-                owner = head cons;
-                branch = last cons;
+                cons = lib.splitString ":" ref;
+                owner = lib.head cons;
+                branch = lib.last cons;
               in
               "https://github.com/${owner}/nixpkgs/archive/refs/heads/${branch}.tar.gz";
             inherit sha256;
@@ -111,5 +114,4 @@ rec {
       )
     ];
   };
-
 }
diff --git a/overlays.nix b/overlays.nix
index 4a4401c..18fe174 100644
--- a/overlays.nix
+++ b/overlays.nix
@@ -1,152 +1,143 @@
-{ inputs, ... }:
 {
-  default = final: prev: {
-    bruh = prev.callPackage ./packages/bruh.nix { };
+  inputs,
+  lib,
+  ...
+}:
+{
+  default =
+    final: prev:
+    lib.infuse.v1.infuse prev {
+      bruh = _: prev.callPackage ./packages/bruh.nix { };
 
-    emacsql-sqlite = prev.callPackage ./packages/emacsql-sqlite.nix { };
+      emacsql-sqlite = _: prev.callPackage ./packages/emacsql-sqlite.nix { };
 
-    git-extras = prev.git-extras.overrideAttrs (
-      _: super: {
-        postPatch =
-          (super.postPatch or "")
-          + ''
-            substituteInPlace bin/git-setup \
-              --replace 'Initial commit' 'chore: init'
-          '';
-      }
-    );
+      git-extras.__output.postPatch.__append = ''
+        substituteInPlace bin/git-setup \
+          --replace 'Initial commit' 'chore: init'
+      '';
 
-    grc = prev.grc.overrideAttrs (
-      _: super: {
-        version = "unstable-2021-08-12";
-        src = final.fetchFromGitHub {
+      grc.__output = {
+        version.__assign = "unstable-2021-08-12";
+        src.__assign = final.fetchFromGitHub {
           owner = "garabik";
           repo = "grc";
           rev = "4d6a51fd78ad7e19af8dd12b2a828d1807267079";
           hash = "sha256-SmOZrgV0lgLryFoxADU15IKJ7jhxXar0MgbsV/z1GaE=";
         };
-        patches = (super.patches or [ ]) ++ [
+        patches.__append = [
           (final.fetchpatch {
             url = "https://patch-diff.githubusercontent.com/raw/garabik/grc/pull/214.patch";
             hash = "sha256-VNr9jl5oFbFNJbGsjflwFV3oTbCzJ0lBIZA4eyeoXLY=";
           })
         ];
-      }
-    );
+      };
 
-    hiccup = prev.callPackage ./packages/hiccup.nix { };
+      hiccup = _: prev.callPackage ./packages/hiccup.nix { };
 
-    lampray = prev.callPackage ./packages/lampray.nix { };
+      lampray = _: prev.callPackage ./packages/lampray.nix { };
 
-    logcli = prev.grafana-loki.overrideAttrs (
-      _: super: {
-        pname = "logcli";
-        subPackages = [ "cmd/logcli" ];
-        nativeBuildInputs = (super.nativeBuildInputs or [ ]) ++ [ final.installShellFiles ];
-        postInstall =
-          (super.postInstall or "")
-          + ''
-            installShellCompletion --cmd logcli \
-              --bash <($out/bin/logcli --completion-script-bash) \
-              --zsh <($out/bin/logcli --completion-script-zsh)
-          '';
-        preFixup = null;
-      }
-    );
+      # TODO Can this be infused?
+      logcli =
+        _:
+        prev.grafana-loki.overrideAttrs (
+          _: super: {
+            pname = "logcli";
+            subPackages = [ "cmd/logcli" ];
+            nativeBuildInputs = (super.nativeBuildInputs or [ ]) ++ [ final.installShellFiles ];
+            postInstall =
+              (super.postInstall or "")
+              + ''
+                installShellCompletion --cmd logcli \
+                  --bash <($out/bin/logcli --completion-script-bash) \
+                  --zsh <($out/bin/logcli --completion-script-zsh)
+              '';
+            preFixup = null;
+          }
+        );
 
-    myip = prev.callPackage ./packages/myip.nix { };
+      myip = _: prev.callPackage ./packages/myip.nix { };
 
-    nixfiles = prev.callPackage ./packages/nixfiles.nix { };
+      nixfiles = _: prev.callPackage ./packages/nixfiles.nix { };
 
-    nixfmt = prev.nixfmt-rfc-style;
+      nixfmt = _: prev.nixfmt-rfc-style;
 
-    openssl_1_0_0 = prev.callPackage ./packages/openssl_1_0_0.nix { };
+      openssl_1_0_0 = _: prev.callPackage ./packages/openssl_1_0_0.nix { };
 
-    telegram-desktop =
-      (prev.telegram-desktop.override (finalAttrs: {
-        stdenv = final.useMoldLinker finalAttrs.stdenv;
-      })).overrideAttrs
-        (
-          _: super: {
-            patches =
-              (super.patches or [ ])
-              ++ (
-                let
-                  patches = "https://raw.githubusercontent.com/msva/mva-overlay/4c89938831bcce03fae22081809e53a47bdee31b/net-im/telegram-desktop/files/patches";
-                in
-                [
-                  (prev.fetchpatch {
-                    url = "${patches}/0/conditional/tdesktop_patches_hide-sponsored-messages/0000-data_data_sponsored_messages.cpp.patch";
-                    hash = "sha256-vVucKG0YNY41MVdqibhKfxL/2/nNPPtYw+otwat971U=";
-                  })
-                  (prev.fetchpatch {
-                    url = "${patches}/0/conditional/tdesktop_patches_allow-disable-stories/option-to-disable-stories.patch";
-                    hash = "sha256-ctL9wIn3cLtqgCcQFNnx7WQuBw+9IjDlMJUicmVt8no=";
-                  })
-                  (prev.fetchpatch {
-                    url = "${patches}/0/conditional/tdesktop_patches_hide-banned/0000_hide-messages-from-blocked-users.patch";
-                    hash = "sha256-61U3wQsUdLvB4ymHPjVecw9WvhW8W/V0Jf1cnvYUkHk=";
-                  })
-                  (prev.fetchpatch {
-                    url = "${patches}/0/conditional/tdesktop_patches_wide-baloons/style.patch";
-                    hash = "sha256-Ot2kb49YsEhaunw/yMgLaqrDYYS+pHPf79Yiwahxj+g=";
-                  })
-                ]
-              );
-          }
-        );
+      telegram-desktop = {
+        __input.stdenv = stdenv: final.useMoldLinker stdenv;
+        __output.patches.__append =
+          let
+            patches = "https://raw.githubusercontent.com/msva/mva-overlay/4c89938831bcce03fae22081809e53a47bdee31b/net-im/telegram-desktop/files/patches/0/conditional";
+          in
+          [
+            (prev.fetchpatch {
+              url = "${patches}/tdesktop_patches_hide-sponsored-messages/0000-data_data_sponsored_messages.cpp.patch";
+              hash = "sha256-vVucKG0YNY41MVdqibhKfxL/2/nNPPtYw+otwat971U=";
+            })
+            (prev.fetchpatch {
+              url = "${patches}/tdesktop_patches_allow-disable-stories/option-to-disable-stories.patch";
+              hash = "sha256-ctL9wIn3cLtqgCcQFNnx7WQuBw+9IjDlMJUicmVt8no=";
+            })
+            (prev.fetchpatch {
+              url = "${patches}/tdesktop_patches_hide-banned/0000_hide-messages-from-blocked-users.patch";
+              hash = "sha256-61U3wQsUdLvB4ymHPjVecw9WvhW8W/V0Jf1cnvYUkHk=";
+            })
+          ];
+      };
 
-    vesktop =
-      (prev.vesktop.overrideAttrs (
-        _: super: {
-          nativeBuildInputs = super.nativeBuildInputs ++ [ final.imagemagick ];
-          patches = (super.patches or [ ]) ++ [ ./packages/vesktop.patch ];
-          postInstall =
-            (super.postInstall or "")
-            + ''
-              rm -rf $out/share/icons/hicolor/*
-              for size in 1024 128 256 32 512 64; do
-                convert -scale $size $src/build/icon.png $size.png
-                install -Dm644 $size.png $out/share/icons/hicolor/''${size}x''${size}/apps/vesktop.png
-              done
-            '';
-        }
-      )).override
-        {
-          withSystemVencord = false;
-          withTTS = false;
+      vesktop = {
+        __input = {
+          withSystemVencord = _: false;
+          withTTS = _: false;
         };
+        __output = {
+          nativeBuildInputs.__append = [ final.imagemagick ];
+          patches.__append = [ ./packages/vesktop.patch ];
+          postInstall.__append = ''
+            rm -rf $out/share/icons/hicolor/*
+            for size in 1024 128 256 32 512 64; do
+              convert -scale $size $src/build/icon.png $size.png
+              install -Dm644 $size.png $out/share/icons/hicolor/''${size}x''${size}/apps/vesktop.png
+            done
+          '';
+        };
+      };
 
-    linuxPackages_latest = prev.linuxPackages_latest.extend (
-      self: _: {
-        amneziawg =
-          inputs.nixpkgs-amneziawg.legacyPackages.${final.system}.linuxPackages_latest.amneziawg.override
-            {
-              inherit (self) kernel;
-            };
-      }
-    );
-    linuxPackages_hardened = prev.linuxPackages_hardened.extend (
-      self: _: {
-        amneziawg =
-          inputs.nixpkgs-amneziawg.legacyPackages.${final.system}.linuxPackages_hardened.amneziawg.override
-            {
-              inherit (self) kernel;
-            };
-      }
-    );
-    linuxPackages_xanmod_latest = prev.linuxPackages_xanmod_latest.extend (
-      self: _: {
-        amneziawg =
-          inputs.nixpkgs-amneziawg.legacyPackages.${final.system}.linuxPackages_xanmod_latest.amneziawg.override
-            {
-              inherit (self) kernel;
-            };
-      }
-    );
-    inherit (inputs.nixpkgs-amneziawg.legacyPackages.${final.system})
-      amneziawg-go
-      amneziawg-tools
-      ;
-  };
+      # TODO Can this be infused?
+      linuxPackages_latest =
+        _:
+        prev.linuxPackages_latest.extend (
+          self: _: {
+            amneziawg =
+              inputs.nixpkgs-amneziawg.legacyPackages.${final.system}.linuxPackages_latest.amneziawg.override
+                {
+                  inherit (self) kernel;
+                };
+          }
+        );
+      linuxPackages_hardened =
+        _:
+        prev.linuxPackages_hardened.extend (
+          self: _: {
+            amneziawg =
+              inputs.nixpkgs-amneziawg.legacyPackages.${final.system}.linuxPackages_hardened.amneziawg.override
+                {
+                  inherit (self) kernel;
+                };
+          }
+        );
+      linuxPackages_xanmod_latest =
+        _:
+        prev.linuxPackages_xanmod_latest.extend (
+          self: _: {
+            amneziawg =
+              inputs.nixpkgs-amneziawg.legacyPackages.${final.system}.linuxPackages_xanmod_latest.amneziawg.override
+                {
+                  inherit (self) kernel;
+                };
+          }
+        );
+      amneziawg-go = _: inputs.nixpkgs-amneziawg.legacyPackages.${final.system}.amneziawg-go;
+      amneziawg-tools = _: inputs.nixpkgs-amneziawg.legacyPackages.${final.system}.amneziawg-tools;
+    };
 }

Consider giving Nix/NixOS a try! <3