feat: add nix package with gomod2nix

This commit is contained in:
Tulili 2024-01-12 04:13:48 -03:00
parent c59bc6958e
commit f7ca05f296
No known key found for this signature in database
5 changed files with 231 additions and 0 deletions

View file

@ -22,6 +22,11 @@ go get -u ./cmd
CGO_ENABLED=0 go build -o quickpassthrough cmd/main.go
```
## Run with Nix
```bash
nix run github:hikariknight/quickpassthrough
```
## Does this work on immutable systems?
Currently no, there might be support for ostree (fedora silverblue, kinoite, etc) at a later time.

21
default.nix Normal file
View file

@ -0,0 +1,21 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
, buildGoApplication ? pkgs.buildGoApplication
}:
buildGoApplication {
pname = "cmd";
version = "2.0.0";
pwd = ./.;
src = ./.;
modules = ./gomod2nix.toml;
}

84
flake.lock generated Normal file
View file

@ -0,0 +1,84 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gomod2nix": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1701687253,
"narHash": "sha256-qJCMxIKWXonJODPF2oV7mCd0xu7VYVenTucrY0bizto=",
"owner": "nix-community",
"repo": "gomod2nix",
"rev": "001bbfa22e2adeb87c34c6015e5694e88721cabe",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "gomod2nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1704842529,
"narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixpkgs-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"gomod2nix": "gomod2nix",
"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
}

31
flake.nix Normal file
View file

@ -0,0 +1,31 @@
{
description = "Quick ";
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
gomod2nix.url = "github:nix-community/gomod2nix";
gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
gomod2nix.inputs.flake-utils.follows = "flake-utils";
};
outputs = { self, nixpkgs, flake-utils, gomod2nix }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { inherit system; };
in {
packages.default = pkgs.callPackage ./. {
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
};
packages.updater = pkgs.writeShellScriptBin "updater" ''
set -euo pipefail
echo "WARNING: This package is for updating this nix package! You should also update default.nix release variable if you wanna update this too"
${pkgs.nix}/bin/nix run github:nix-community/gomod2nix
'';
devShells.default = pkgs.mkShell {
packages = with pkgs; [ nil go gopls ];
};
}
);
}

90
gomod2nix.toml Normal file
View file

@ -0,0 +1,90 @@
schema = 3
[mod]
[mod."github.com/HikariKnight/ls-iommu"]
version = "v0.0.0-20230912061539-899ed0ca3fd5"
hash = "sha256-7rwnT0wdvOGVP8MgvxJfodTeO1MeMr0ojE53AwSk1FU="
[mod."github.com/akamensky/argparse"]
version = "v1.4.0"
hash = "sha256-jKPGPXQNVhQN1FDuqS7V7RU2ltDt3uLzWp1nz13++dQ="
[mod."github.com/atotto/clipboard"]
version = "v0.1.4"
hash = "sha256-ZZ7U5X0gWOu8zcjZcWbcpzGOGdycwq0TjTFh/eZHjXk="
[mod."github.com/aymanbagabas/go-osc52/v2"]
version = "v2.0.1"
hash = "sha256-6Bp0jBZ6npvsYcKZGHHIUSVSTAMEyieweAX2YAKDjjg="
[mod."github.com/buger/goterm"]
version = "v1.0.4"
hash = "sha256-NKhi8NIals19zDX72Elu0TXthGw2+uPHHQ6pyETaESo="
[mod."github.com/cavaliergopher/grab/v3"]
version = "v3.0.1"
hash = "sha256-7yixBq4kPAp+NqHvEC4xCKFwI5bqSbZfzdVVLwvMvl4="
[mod."github.com/charmbracelet/bubbles"]
version = "v0.17.1"
hash = "sha256-rY9OhTEF4E7Dl28NqLesgI3grQoqJMhTnaAKTGYYEL8="
[mod."github.com/charmbracelet/bubbletea"]
version = "v0.25.0"
hash = "sha256-A0WjFRFAUhwO3m7uvCOeefPPIM8ReU+xTtIRxG0aH+Y="
[mod."github.com/charmbracelet/lipgloss"]
version = "v0.9.1"
hash = "sha256-AHbabOymgDRIXsMBgJHS25/GgBWT54oGbd15EBWKeZc="
[mod."github.com/containerd/console"]
version = "v1.0.4-0.20230313162750-1ae8d489ac81"
hash = "sha256-Qus81DgpWHJ6RRqeKOKcUFvzCxvPzygJqBabvBsBuHU="
[mod."github.com/gookit/color"]
version = "v1.5.4"
hash = "sha256-6Xydefyslup+qohzatAdezGWrS065X5mx18wvRef3Rk="
[mod."github.com/klauspost/cpuid/v2"]
version = "v2.2.6"
hash = "sha256-SlMBrOvotgIvGI7GsUmNxs++KpgzNCk1jOBAl8Oq8c8="
[mod."github.com/lucasb-eyer/go-colorful"]
version = "v1.2.0"
hash = "sha256-Gg9dDJFCTaHrKHRR1SrJgZ8fWieJkybljybkI9x0gyE="
[mod."github.com/mattn/go-isatty"]
version = "v0.0.20"
hash = "sha256-qhw9hWtU5wnyFyuMbKx+7RB8ckQaFQ8D+8GKPkN3HHQ="
[mod."github.com/mattn/go-localereader"]
version = "v0.0.1"
hash = "sha256-JlWckeGaWG+bXK8l8WEdZqmSiTwCA8b1qbmBKa/Fj3E="
[mod."github.com/mattn/go-runewidth"]
version = "v0.0.15"
hash = "sha256-WP39EU2UrQbByYfnwrkBDoKN7xzXsBssDq3pNryBGm0="
[mod."github.com/muesli/ansi"]
version = "v0.0.0-20230316100256-276c6243b2f6"
hash = "sha256-qRKn0Bh2yvP0QxeEMeZe11Vz0BPFIkVcleKsPeybKMs="
[mod."github.com/muesli/cancelreader"]
version = "v0.2.2"
hash = "sha256-uEPpzwRJBJsQWBw6M71FDfgJuR7n55d/7IV8MO+rpwQ="
[mod."github.com/muesli/reflow"]
version = "v0.3.0"
hash = "sha256-Pou2ybE9SFSZG6YfZLVV1Eyfm+X4FuVpDPLxhpn47Cc="
[mod."github.com/muesli/termenv"]
version = "v0.15.2"
hash = "sha256-Eum/SpyytcNIchANPkG4bYGBgcezLgej7j/+6IhqoMU="
[mod."github.com/nexidian/gocliselect"]
version = "v1.0.0"
hash = "sha256-ZL8V/xFuW9DTPaHbvkmfW+o0b7UuoEzbZSEJ7TD1wlA="
[mod."github.com/pkg/term"]
version = "v1.1.0"
hash = "sha256-4zgH0pWzCb8f/98ACk+GPF1D5iFBjzr+Ybjsb4qQnjo="
[mod."github.com/rivo/uniseg"]
version = "v0.4.4"
hash = "sha256-B8tbL9K6ICLdm0lEhs9+h4cpjAfvFtNiFMGvQZmw0bM="
[mod."github.com/sahilm/fuzzy"]
version = "v0.1.1-0.20230530133925-c48e322e2a8f"
hash = "sha256-f2VsDI6G+V2w31tSDzbZPi9EI2E7jRV6Aq8yeOorSZY="
[mod."github.com/xo/terminfo"]
version = "v0.0.0-20220910002029-abceb7e1c41e"
hash = "sha256-GyCDxxMQhXA3Pi/TsWXpA8cX5akEoZV7CFx4RO3rARU="
[mod."golang.org/x/sync"]
version = "v0.5.0"
hash = "sha256-EAKeODSsct5HhXPmpWJfulKSCkuUu6kkDttnjyZMNcI="
[mod."golang.org/x/sys"]
version = "v0.15.0"
hash = "sha256-n7TlABF6179RzGq3gctPDKDPRtDfnwPdjNCMm8ps2KY="
[mod."golang.org/x/term"]
version = "v0.15.0"
hash = "sha256-rsvtsE7sKmBwtR+mhJ8iUq93ZT8fV2LU+Pd69sh2es8="
[mod."golang.org/x/text"]
version = "v0.14.0"
hash = "sha256-yh3B0tom1RfzQBf1RNmfdNWF1PtiqxV41jW1GVS6JAg="