Skip to content

Commit

Permalink
Merge pull request #1 from nais/install-with-nix
Browse files Browse the repository at this point in the history
Add a nix build
  • Loading branch information
Kyrremann authored Jun 27, 2023
2 parents 5f4bd49 + 73a462f commit 4fc460e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
26 changes: 26 additions & 0 deletions flake.lock

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

60 changes: 60 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
description = "Narcos";

# Nixpkgs / NixOS version to use.
inputs.nixpkgs.url = "github:nixos/nixpkgs";

outputs = { self, nixpkgs }:
let

# Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;

# System types to support.
supportedSystems =
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];

# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });

# Remove .gits etc from the build inputs
src = nixpkgs.lib.cleanSource ./.;

in {

# Provide some binary packages for selected system types.
packages = forAllSystems (system:
let pkgs = nixpkgsFor.${system};
in {
# The default package for 'nix build'. This makes sense if the
# flake provides only one package or there is a clear "main"
# package.
default = pkgs.buildGoModule {
pname = "narcos";
inherit version;
inherit src;

# how do i goflags this?
postInstall = ''
mv $out/bin/cmd $out/bin/narc
'';

# This hash locks the dependencies of this package. It is
# necessary because of how Go requires network access to resolve
# VCS. See https://www.tweag.io/blog/2021-03-04-gomod2nix/ for
# details. Normally one can build with a fake sha256 and rely on native Go
# mechanisms to tell you what the hash should be or determine what
# it should be "out-of-band" with other tooling (eg. gomod2nix).
# To begin with it is recommended to set this, but one must
# remeber to bump this hash when your dependencies change.
#vendorSha256 = pkgs.lib.fakeSha256;

vendorSha256 =
"sha256-gJrXz6fUp4xlUg2X4zTid1ORUIqZiPqXo5THSCtIS8E=";
};
});
};
}

0 comments on commit 4fc460e

Please sign in to comment.