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 deleted file mode 100644 index cce312c7f..000000000 --- a/flake-explorations/flake-with-both-shell-and-flake.nix +++ /dev/null @@ -1,41 +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 b69edabe2..000000000 --- a/flake-explorations/flake.nix +++ /dev/null @@ -1,36 +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 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..0097bf628 100644 --- a/shell.nix +++ b/shell.nix @@ -1,37 +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 - gopls - tmux - gofumpt - olderVersionOfGolangci-lint - gosec - delve - go-tools - gotests - gomodifytags - ]; - # pkgs.system="x86_64-linux"; - } - # ) \ No newline at end of file +pkgs.mkShell { + packages = with pkgs; [ + go + gopls + tmux + gofumpt + golangci-lint + gosec + delve + gotools + gotests + gomodifytags + ]; +}