From 87cfe2c622ea0571b0384c8c21378854bd798658 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Sun, 17 Nov 2024 03:52:35 +0000 Subject: [PATCH] Add nix flake files --- flake.lock | 26 ++++++++++++++++++++++++++ flake.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..caef11e --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1731799881, + "narHash": "sha256-GRlDXqmwJoW3F0Ymn0ETLsxujLD5idvdaDEzIjF5EEs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cd43d6867192ddfb98ba106065a89790e2722b3f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a6393c4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,53 @@ +{ + description = "Nix notes.sh dev environment"; + + # Flake inputs + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + }; + + # Flake outputs + outputs = { self, nixpkgs }: + let + # Systems supported + allSystems = [ + "x86_64-linux" # 64-bit Intel/AMD Linux + "aarch64-linux" # 64-bit ARM Linux + "x86_64-darwin" # 64-bit Intel macOS + "aarch64-darwin" # 64-bit ARM macOS + ]; + + # Helper to provide system-specific attributes + forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f { + pkgs = import nixpkgs { inherit system; }; + }); + + make_package = pkgs: pkgs.stdenv.mkDerivation { + name = "notes-sh"; + src = self; + nativeBuildInputs = [pkgs.makeWrapper]; + installPhase = '' + mkdir -p $out/bin + cp notes.sh $out/bin + ''; + + postFixup = '' + wrapProgram $out/bin/notes.sh \ + --prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [ gawk findutils gnused coreutils])} + ''; + }; + in + { + devShells = forAllSystems ({ pkgs }: { + default = pkgs.mkShell { + packages = with pkgs; [ + fzf + ]; + }; + }); + packages = forAllSystems({ pkgs }: rec {notes-sh = make_package pkgs; default=notes-sh;}); + overlays.default = final: prev: { + notes-sh = make_package prev; + }; + }; +}