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 d4bb0a0..353aeef 100644 --- a/flake.nix +++ b/flake.nix @@ -1,27 +1,27 @@ { - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - }; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - 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 - gcc - ]; - }; - } - ); + 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 { }; + }); + + 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..257a285 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,18 @@ +{ + go, + gopls, + goreleaser, + callPackage, + gcc +}: +let + mainPkg = callPackage ./default.nix { }; +in +mainPkg.overrideAttrs (oa: { + nativeBuildInputs = [ + go + gopls + goreleaser + gcc + ] ++ (oa.nativeBuildInputs or [ ]); +})