From 6938f408da08e1e686e047f176e4565ffb57b52c Mon Sep 17 00:00:00 2001 From: yemou Date: Sat, 06 Jan 2024 19:47:54 +0000 Subject: [PATCH] Add initial nix flake --- .gitignore | 1 + flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 34 ++++++++++++++++++++++++++++++++++ .nix/colorgrab.nix | 37 +++++++++++++++++++++++++++++++++++++ .nix/prefon.nix | 22 ++++++++++++++++++++++ .nix/scr.nix | 37 +++++++++++++++++++++++++++++++++++++ .nix/thm.nix | 24 ++++++++++++++++++++++++ 7 file(s) changed, 182 insertion(s)(+), 0 deletion(s)(-) diff --git a/.gitignore b/.gitignore new file mode 100644 --- /dev/null +++ b/.gitignore @@ -0,0 +1,1 @@ +result* diff --git a/flake.lock b/flake.lock new file mode 100644 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1704194953, + "narHash": "sha256-RtDKd8Mynhe5CFnVT8s0/0yqtWFMM9LmCzXv/YKxnq4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bd645e8668ec6612439a9ee7e71f7eac4099d4f6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs, ... }: { + overlays.default = final: prev: rec { + colorgrab = final.callPackage ./.nix/colorgrab.nix { }; + prefon = final.callPackage ./.nix/prefon.nix { }; + scr = final.callPackage ./.nix/scr.nix { }; + thm = final.callPackage ./.nix/thm.nix { }; + yemou-scripts = final.symlinkJoin { + name = "yemou-scripts"; + paths = [ colorgrab prefon scr thm ]; + }; + }; + + packages."x86_64-linux" = + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ self.overlays.default ]; + }; + in + { + colorgrab = pkgs.colorgrab; + default = pkgs.yemou-scripts; + prefon = pkgs.prefon; + scr = pkgs.scr; + thm = pkgs.thm; + yemou-scripts = pkgs.yemou-scripts; + }; + }; +} diff --git a/.nix/colorgrab.nix b/.nix/colorgrab.nix new file mode 100644 --- /dev/null +++ b/.nix/colorgrab.nix @@ -0,0 +1,37 @@ +{ writeScriptBin +, bash +, coreutils +, grim +, imagemagick +, libnotify +, slurp +, wl-clipboard +, xdg-utils +, ... +}: + +writeScriptBin "colorgrab" (builtins.replaceStrings + [ + "#!/bin/sh" + "mkdir" + "printf" + "grim" + "slurp" + "convert" + "wl-copy" + "xdg-open" + "notify-send" + ] + [ + "#!${bash}/bin/sh" + "${coreutils}/bin/mkdir" + "${coreutils}/bin/printf" + "${grim}/bin/grim" + "${slurp}/bin/slurp" + "${imagemagick}/bin/convert" + "${wl-clipboard}/bin/wl-copy" + "${xdg-utils}/bin/xdg-open" + "${libnotify}/bin/notify-send" + ] + (builtins.readFile ../scritps/colorgrab) +) diff --git a/.nix/prefon.nix b/.nix/prefon.nix new file mode 100644 --- /dev/null +++ b/.nix/prefon.nix @@ -0,0 +1,22 @@ +{ writeScriptBin +, bash +, coreutils +, imagemagick +, ... +}: + +writeScriptBin "prefon" (builtins.replaceStrings + [ + "#!/bin/sh" + "printf" + "convert" + "rm" + ] + [ + "#!${bash}/bin/sh" + "${coreutils}/bin/printf" + "${imagemagick}/bin/convert" + "${coreutils}/bin/rm" + ] + (builtins.readFile ../scritps/prefon) +) diff --git a/.nix/scr.nix b/.nix/scr.nix new file mode 100644 --- /dev/null +++ b/.nix/scr.nix @@ -0,0 +1,37 @@ +{ writeScriptBin +, bash +, coreutils +, ffmpeg +, grim +, pulseaudio +, slurp +, wf-recorder +, wl-clipboard +, ... +}: + +writeScriptBin "scr" (builtins.replaceStrings + [ + "#!/bin/sh" + "printf" + "mkdir" + "ffmpeg" + "grim" + "slurp" + "wl-copy" + "pactl" + "wf-recorder" + ] + [ + "#!${bash}/bin/sh" + "${coreutils}/bin/printf" + "${coreutils}/bin/mkdir" + "${ffmpeg}/bin/ffmpeg" + "${grim}/bin/grim" + "${slurp}/bin/slurp" + "${wl-clipboard}/bin/wl-copy" + "${pulseaudio}/bin/pactl" + "${wf-recorder}/bin/wf-recorder" + ] + (builtins.readFile ../scritps/scr) +) diff --git a/.nix/thm.nix b/.nix/thm.nix new file mode 100644 --- /dev/null +++ b/.nix/thm.nix @@ -0,0 +1,24 @@ +{ writeScriptBin +, bash +, coreutils +, gnused +, ... +}: + +writeScriptBin "thm" (builtins.replaceStrings + [ + "#!/bin/sh" + "printf" + "mkdir" + "mv" + "sed" + ] + [ + "#!${bash}/bin/sh" + "${coreutils}/bin/printf" + "${coreutils}/bin/mkdir" + "${coreutils}/bin/mv" + "${gnused}/bin/sed" + ] + (builtins.readFile ../scritps/thm) +) -- tangled.sh