Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nix flake #47

Open
wants to merge 4 commits into
base: feat/v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 3 additions & 37 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 24 additions & 24 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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 { };
});
};
}
36 changes: 36 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -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";
}
17 changes: 17 additions & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
go,
gopls,
goreleaser,
callPackage,
sgoudham marked this conversation as resolved.
Show resolved Hide resolved
}:
let
mainPkg = callPackage ./default.nix { };
in
mainPkg.overrideAttrs (oa: {
nativeBuildInputs = [
go
gopls
goreleaser
sgoudham marked this conversation as resolved.
Show resolved Hide resolved
gcc
] ++ (oa.nativeBuildInputs or [ ]);
})