From d096564af91f884d4ad02c129203eb41af3e45fe Mon Sep 17 00:00:00 2001 From: isabel Date: Sun, 2 Jun 2024 22:38:41 +0100 Subject: [PATCH 1/3] feat: nix flake --- flake.lock | 40 +++------------------------------------- flake.nix | 47 +++++++++++++++++++++++------------------------ nix/default.nix | 36 ++++++++++++++++++++++++++++++++++++ nix/shell.nix | 16 ++++++++++++++++ 4 files changed, 78 insertions(+), 61 deletions(-) create mode 100644 nix/default.nix create mode 100644 nix/shell.nix diff --git a/flake.lock b/flake.lock index b464740..8650720 100644 --- a/flake.lock +++ b/flake.lock @@ -1,30 +1,12 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1694767346, - "narHash": "sha256-5uH27SiVFUwsTsqC5rs3kS7pBoNhtoy9QfTP9BmknGk=", + "lastModified": 1716948383, + "narHash": "sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ace5093e36ab1e95cb9463863491bee90d5a4183", + "rev": "ad57eef4ef0659193044870c731987a6df5cf56b", "type": "github" }, "original": { @@ -36,24 +18,8 @@ }, "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", diff --git a/flake.nix b/flake.nix index bcbbe8a..353aeef 100644 --- a/flake.nix +++ b/flake.nix @@ -1,28 +1,27 @@ { - description = "A devShell example"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - }; + outputs = + { nixpkgs, ... }: + let + systems = [ + "x86_64-linux" + "x86_64-darwin" + "i686-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + forAllSystems = + function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system}); + in + { + packages = forAllSystems (pkgs: rec { + default = ctp; + ctp = pkgs.callPackage ./nix/default.nix { }; + }); - outputs = { self, nixpkgs, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - overlays = [ ]; - pkgs = import nixpkgs { - inherit system overlays; - }; - in - with pkgs; - { - devShell = mkShell { - buildInputs = [ - go - gopls - goreleaser - ]; - }; - } - ); + devShells = forAllSystems (pkgs: { + default = pkgs.callPackage ./nix/shell.nix { }; + }); + }; } diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..f84e8f2 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,36 @@ +{ lib, buildGoModule }: +let + version = "unstable"; +in +buildGoModule { + pname = "catppuccin-cli"; + inherit version; + + src = lib.fileset.toSource { + root = ../.; + fileset = lib.fileset.intersection (lib.fileset.fromSource (lib.sources.cleanSource ../.)) ( + lib.fileset.unions [ + ../go.mod + ../go.sum + ../main.go + ../commands + ../query + ../shared + ] + ); + }; + + vendorHash = "sha256-kwTPdktn1p4E/PvJ5kLDZZ0cZdx3u6gvFaPvtaeO8nw="; + + ldflags = [ + "-s" + "-w" + "-X main.version=${version}" + ]; + + postInstall = '' + mv $out/bin/cli $out/bin/ctp + ''; + + meta.mainPackage = "ctp"; +} diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..f0af32f --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,16 @@ +{ + go, + gopls, + goreleaser, + callPackage, +}: +let + mainPkg = callPackage ./default.nix { }; +in +mainPkg.overrideAttrs (oa: { + nativeBuildInputs = [ + go + gopls + goreleaser + ] ++ (oa.nativeBuildInputs or [ ]); +}) From e281d37b80630908415f802a72b9f5b8ac12a2d4 Mon Sep 17 00:00:00 2001 From: Hammy <58985301+sgoudham@users.noreply.github.com> Date: Sun, 2 Jun 2024 23:34:14 +0100 Subject: [PATCH 2/3] Update nix/shell.nix --- nix/shell.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/shell.nix b/nix/shell.nix index f0af32f..917005c 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -12,5 +12,6 @@ mainPkg.overrideAttrs (oa: { go gopls goreleaser + gcc ] ++ (oa.nativeBuildInputs or [ ]); }) From 2e485da417ca2bc1b407993a805bb21c0a37da54 Mon Sep 17 00:00:00 2001 From: Hammy <58985301+sgoudham@users.noreply.github.com> Date: Sun, 2 Jun 2024 23:34:33 +0100 Subject: [PATCH 3/3] Update nix/shell.nix --- nix/shell.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/shell.nix b/nix/shell.nix index 917005c..257a285 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -3,6 +3,7 @@ gopls, goreleaser, callPackage, + gcc }: let mainPkg = callPackage ./default.nix { };