From 336e944abef87e46862959c6a3c3df95cb49ed4d Mon Sep 17 00:00:00 2001 From: chandler-barlow Date: Wed, 8 Apr 2026 23:06:04 +0000 Subject: [PATCH 1/3] feat: added nix --- default.nix | 36 ++++++++++ .../flake-with-both-shell-and-flake.nix | 70 ++++++++++-------- flake-explorations/flake.nix | 44 +++++++----- flake.lock | 67 +++++++++++++++-- flake.nix | 52 ++++++++++---- shell.nix | 72 ++++++++++--------- 6 files changed, 240 insertions(+), 101 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 000000000..983747e29 --- /dev/null +++ b/default.nix @@ -0,0 +1,36 @@ +{ + lib, + buildGo125Module, + version, + ... +}: +let + pname = "brev"; +in +buildGo125Module { + inherit version pname; + src = ./.; + + env.CGO_ENABLED = 1; + hardeningDisable = [ "bindnow" ]; + subPackages = [ "." ]; + + ldflags = [ + "-s" + "-w" + "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${version}" + ]; + + vendorHash = "sha256-rB6uqkpnc+SlbzNvtTOnDCIJIpxoiyPb/lsiRYkDltg="; + + postInstall = '' + mv $out/bin/brev-cli $out/bin/brev + ''; + + meta = { + description = "CLI tool for managing workspaces provided by brev.nvidia.com"; + homepage = "https://docs.nvidia.com/brev/latest/"; + license = lib.licenses.mit; + mainProgram = pname; + }; +} diff --git a/flake-explorations/flake-with-both-shell-and-flake.nix b/flake-explorations/flake-with-both-shell-and-flake.nix index cce312c7f..0e3a27a0a 100644 --- a/flake-explorations/flake-with-both-shell-and-flake.nix +++ b/flake-explorations/flake-with-both-shell-and-flake.nix @@ -1,41 +1,49 @@ { description = "golang development environment "; - -inputs = { + + inputs = { flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem - (system: - let pkgs = nixpkgs.legacyPackages.${system}; + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; pkgs.currentSystem = system; pkgs = import (builtins.fetchGit { - # Descriptive name to make the store path easier to identify - name = "my-old-revision"; - url = "https://github.com/NixOS/nixpkgs/"; - ref = "refs/heads/nixpkgs-unstable"; - rev = "ff8b619cfecb98bb94ae49ca7ceca937923a75fa"; - }) {}; - myPkg = pkgs.golangci-lint; - in - { - # devShell = import ./shell.nix { inherit pkgs; }; - devShell = pkgs.mkShell { buildInputs = [ - pkgs.go_1_18 - pkgs.gopls - pkgs.tmux - pkgs.gofumpt - myPkg - pkgs.gosec - pkgs.delve - pkgs.go-tools - pkgs.gotests - pkgs.gomodifytags - ]; currentSystem = system; }; - } - ); + # Descriptive name to make the store path easier to identify + name = "my-old-revision"; + url = "https://github.com/NixOS/nixpkgs/"; + ref = "refs/heads/nixpkgs-unstable"; + rev = "ff8b619cfecb98bb94ae49ca7ceca937923a75fa"; + }) { }; + myPkg = pkgs.golangci-lint; + in + { + # devShell = import ./shell.nix { inherit pkgs; }; + devShell = pkgs.mkShell { + buildInputs = [ + pkgs.go_1_18 + pkgs.gopls + pkgs.tmux + pkgs.gofumpt + myPkg + pkgs.gosec + pkgs.delve + pkgs.go-tools + pkgs.gotests + pkgs.gomodifytags + ]; + currentSystem = system; + }; + } + ); } diff --git a/flake-explorations/flake.nix b/flake-explorations/flake.nix index b69edabe2..929e57928 100644 --- a/flake-explorations/flake.nix +++ b/flake-explorations/flake.nix @@ -2,7 +2,7 @@ # inputs = { # nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # }; -# outputs = { self, nixpkgs }: +# outputs = { self, nixpkgs }: # let # pkgs = nixpkgs.legacyPackages.x86_64-linux; # in @@ -13,24 +13,36 @@ # devShell.x86_64-linux = pkgs.mkShell { # buildInputs = [ self.packages.x86_64-linux.hello self.packages.x86_64-linux.hello2 ]; # }; - + # }; # } { - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - # foo = "bar"; - packages.hello = pkgs.hello; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + # foo = "bar"; + packages.hello = pkgs.hello; - devShell = pkgs.mkShell { buildInputs = [ pkgs.hello pkgs.cowsay ]; }; - }); + devShell = pkgs.mkShell { + buildInputs = [ + pkgs.hello + pkgs.cowsay + ]; + }; + } + ); } diff --git a/flake.lock b/flake.lock index 4dd0d57d8..37cf61cf7 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -17,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1665349835, - "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=", + "lastModified": 1775423009, + "narHash": "sha256-vPKLpjhIVWdDrfiUM8atW6YkIggCEKdSAlJPzzhkQlw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1", + "rev": "68d8aa3d661f0e6bd5862291b5bb263b2a6595c9", "type": "github" }, "original": { @@ -31,10 +34,60 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1770107345, + "narHash": "sha256-tbS0Ebx2PiA1FRW8mt8oejR0qMXmziJmPaU1d4kYY9g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4533d9293756b63904b7238acb84ac8fe4c8c2c4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1775636079, + "narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index aab55acd3..46b7295a1 100644 --- a/flake.nix +++ b/flake.nix @@ -1,20 +1,44 @@ { - description = "golang instance "; - -inputs = { + description = "NVIDIA Brev CLI"; + + inputs = { flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + treefmt-nix.url = "github:numtide/treefmt-nix"; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem - (system: - let pkgs = nixpkgs.legacyPackages.${system}; in - { - devShell = import ./shell.nix { inherit pkgs system; }; - shellHook = '' - echo "hallo" - ''; - } - ); + outputs = + { + self, + nixpkgs, + flake-utils, + treefmt-nix, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + version = self.shortRev or self.dirtyShortRev or "dev"; + brev-cli = pkgs.callPackage ./default.nix { inherit version; }; + treefmtEval = treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; + }; + in + { + formatter = treefmtEval.config.build.wrapper; + + packages = { + default = brev-cli; + inherit brev-cli; + }; + + apps.default = flake-utils.lib.mkApp { + drv = brev-cli; + }; + + devShells.default = import ./shell.nix { inherit pkgs system; }; + devShell = self.devShells.${system}.default; + } + ); } diff --git a/shell.nix b/shell.nix index 8dce0b49e..c4b8a71ab 100644 --- a/shell.nix +++ b/shell.nix @@ -1,37 +1,43 @@ -{ system ? builtins.currentSystem, pkgs ? import { inherit system; } }: +{ + system ? builtins.currentSystem, + pkgs ? import { inherit system; }, +}: with pkgs; let - pkgs = import (builtins.fetchGit { - # Descriptive name to make the store path easier to identify - name = "my-old-revision"; - url = "https://github.com/NixOS/nixpkgs/"; - ref = "refs/heads/nixpkgs-unstable"; - rev = "ff8b619cfecb98bb94ae49ca7ceca937923a75fa"; - # }) {}; - }) { - inherit system; - }; - flake-utils = { - url = "github:numtide/flake-utils"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - olderVersionOfGolangci-lint = pkgs.golangci-lint; - # system = builtins.currentSystem; + pkgs = + import + (builtins.fetchGit { + # Descriptive name to make the store path easier to identify + name = "my-old-revision"; + url = "https://github.com/NixOS/nixpkgs/"; + ref = "refs/heads/nixpkgs-unstable"; + rev = "ff8b619cfecb98bb94ae49ca7ceca937923a75fa"; + # }) {}; + }) + { + inherit system; + }; + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + olderVersionOfGolangci-lint = pkgs.golangci-lint; + # system = builtins.currentSystem; in - mkShell { - nativeBuildInputs = [ - go_1_19 - gopls - tmux - gofumpt - olderVersionOfGolangci-lint - gosec - delve - go-tools - gotests - gomodifytags - ]; - # pkgs.system="x86_64-linux"; - } - # ) \ No newline at end of file +mkShell { + nativeBuildInputs = [ + go_1_19 + gopls + tmux + gofumpt + olderVersionOfGolangci-lint + gosec + delve + go-tools + gotests + gomodifytags + ]; + # pkgs.system="x86_64-linux"; +} +# ) From 3eadabc951fb343cc6cdd2d7578578aceeb6a888 Mon Sep 17 00:00:00 2001 From: chandler-barlow Date: Wed, 8 Apr 2026 23:13:01 +0000 Subject: [PATCH 2/3] removed flake explorations --- .../flake-with-both-shell-and-flake.nix | 49 ------------------- flake-explorations/flake.lock | 43 ---------------- flake-explorations/flake.nix | 48 ------------------ flake-explorations/result | 1 - 4 files changed, 141 deletions(-) delete mode 100644 flake-explorations/flake-with-both-shell-and-flake.nix delete mode 100644 flake-explorations/flake.lock delete mode 100644 flake-explorations/flake.nix delete mode 120000 flake-explorations/result diff --git a/flake-explorations/flake-with-both-shell-and-flake.nix b/flake-explorations/flake-with-both-shell-and-flake.nix deleted file mode 100644 index 0e3a27a0a..000000000 --- a/flake-explorations/flake-with-both-shell-and-flake.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - description = "golang development environment "; - - inputs = { - flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - - }; - - outputs = - { - self, - nixpkgs, - flake-utils, - }: - flake-utils.lib.eachDefaultSystem ( - system: - let - pkgs = nixpkgs.legacyPackages.${system}; - pkgs.currentSystem = system; - pkgs = import (builtins.fetchGit { - # Descriptive name to make the store path easier to identify - name = "my-old-revision"; - url = "https://github.com/NixOS/nixpkgs/"; - ref = "refs/heads/nixpkgs-unstable"; - rev = "ff8b619cfecb98bb94ae49ca7ceca937923a75fa"; - }) { }; - myPkg = pkgs.golangci-lint; - in - { - # devShell = import ./shell.nix { inherit pkgs; }; - devShell = pkgs.mkShell { - buildInputs = [ - pkgs.go_1_18 - pkgs.gopls - pkgs.tmux - pkgs.gofumpt - myPkg - pkgs.gosec - pkgs.delve - pkgs.go-tools - pkgs.gotests - pkgs.gomodifytags - ]; - currentSystem = system; - }; - } - ); -} diff --git a/flake-explorations/flake.lock b/flake-explorations/flake.lock deleted file mode 100644 index 4dd0d57d8..000000000 --- a/flake-explorations/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1665349835, - "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake-explorations/flake.nix b/flake-explorations/flake.nix deleted file mode 100644 index 929e57928..000000000 --- a/flake-explorations/flake.nix +++ /dev/null @@ -1,48 +0,0 @@ -# { -# inputs = { -# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; -# }; -# outputs = { self, nixpkgs }: -# let -# pkgs = nixpkgs.legacyPackages.x86_64-linux; -# in -# { -# # foo = "bar"; -# packages.x86_64-linux.hello = pkgs.hello; -# packages.x86_64-linux.hello2 = pkgs.cowsay; -# devShell.x86_64-linux = pkgs.mkShell { -# buildInputs = [ self.packages.x86_64-linux.hello self.packages.x86_64-linux.hello2 ]; -# }; - -# }; -# } - -{ - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - }; - outputs = - { - self, - nixpkgs, - flake-utils, - }: - flake-utils.lib.eachDefaultSystem ( - system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - # foo = "bar"; - packages.hello = pkgs.hello; - - devShell = pkgs.mkShell { - buildInputs = [ - pkgs.hello - pkgs.cowsay - ]; - }; - } - ); -} diff --git a/flake-explorations/result b/flake-explorations/result deleted file mode 120000 index 74b31f0fa..000000000 --- a/flake-explorations/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/gl5a41azbpsadfkfmbilh9yk40dh5dl0-hello-2.12.1 \ No newline at end of file From fd9e23e7e0da0b1653cf9263f54e2d5a6b16b272 Mon Sep 17 00:00:00 2001 From: chandler-barlow Date: Tue, 14 Apr 2026 10:31:25 -0700 Subject: [PATCH 3/3] updated shell --- shell.nix | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/shell.nix b/shell.nix index c4b8a71ab..0097bf628 100644 --- a/shell.nix +++ b/shell.nix @@ -1,43 +1,16 @@ -{ - system ? builtins.currentSystem, - pkgs ? import { inherit system; }, -}: +{ pkgs }: -with pkgs; -let - pkgs = - import - (builtins.fetchGit { - # Descriptive name to make the store path easier to identify - name = "my-old-revision"; - url = "https://github.com/NixOS/nixpkgs/"; - ref = "refs/heads/nixpkgs-unstable"; - rev = "ff8b619cfecb98bb94ae49ca7ceca937923a75fa"; - # }) {}; - }) - { - inherit system; - }; - flake-utils = { - url = "github:numtide/flake-utils"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - olderVersionOfGolangci-lint = pkgs.golangci-lint; - # system = builtins.currentSystem; -in -mkShell { - nativeBuildInputs = [ - go_1_19 +pkgs.mkShell { + packages = with pkgs; [ + go gopls tmux gofumpt - olderVersionOfGolangci-lint + golangci-lint gosec delve - go-tools + gotools gotests gomodifytags ]; - # pkgs.system="x86_64-linux"; } -# )