~zethra/license

32d339b84166e31805c0314d46081e13a4ae9936 — Sashanoraa 6 months ago 37cb4de
Add Nix flake
3 files changed, 110 insertions(+), 1 deletions(-)

M .gitignore
A flake.lock
A flake.nix
M .gitignore => .gitignore +2 -1
@@ 1,3 1,4 @@
target
result
.envrc
.direnv
\ No newline at end of file
.direnv

A flake.lock => flake.lock +60 -0
@@ 0,0 1,60 @@
{
  "nodes": {
    "flake-utils": {
      "inputs": {
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1689068808,
        "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1690470004,
        "narHash": "sha256-l57RmPhPz9r1LGDg/0v8bYgJO8R+GGTQZtkIxE7negU=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "9462344318b376e157c94fa60c20a25b913b2381",
        "type": "github"
      },
      "original": {
        "id": "nixpkgs",
        "ref": "nixos-23.05",
        "type": "indirect"
      }
    },
    "root": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nixpkgs": "nixpkgs"
      }
    },
    "systems": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}

A flake.nix => flake.nix +48 -0
@@ 0,0 1,48 @@
{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-23.05";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem
      (system:
        let
          pkgs = nixpkgs.legacyPackages.${system};
					lib = pkgs.lib;
        in
        rec {
          packages = rec {
            license = pkgs.rustPlatform.buildRustPackage rec {
              pname = "license";
              version = "3.0.0";
              src = ./.;
              nativeBuildInputs = [ pkgs.installShellFiles pkgs.makeWrapper ];
              preInstall = ''
                ${pkgs.scdoc}/bin/scdoc < doc/license.scd > license.1
              '';
              cargoLock = {
                lockFile = "${src}/Cargo.lock";
                allowBuiltinFetchGit = true;
              };
              postInstall = ''
                installShellCompletion completions/license.{bash,fish}
                installShellCompletion --zsh completions/_license
                installManPage ./license.1

                install -Dm0755 ./scripts/set-license -t $out/bin
                wrapProgram $out/bin/set-license \
                  --prefix PATH : "$out/bin" \
                  --prefix PATH : ${lib.makeBinPath [ pkgs.fzf ]}

                install -Dm0755 ./scripts/copy-header -t $out/bin
                wrapProgram $out/bin/copy-header \
                  --prefix PATH : "$out/bin" \
                  --prefix PATH : ${lib.makeBinPath [ pkgs.wl-clipboard pkgs.xclip ]}
              '';
            };
            default = license;
          };

        });
}