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

fix: run with 'nix run' #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all 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
21 changes: 19 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
};
linuxInterpreter = linuxInterpreters.${pkgs.stdenv.hostPlatform.parsed.cpu.name};
in
{
rec {
tsui = pkgs.buildGoModule {
inherit pname;
inherit version;
Expand All @@ -65,12 +65,24 @@
vendorHash = "sha256-FIbkPE5KQ4w7Tc7kISQ7ZYFZAoMNGiVlFWzt8BPCf+A=";

buildInputs = dependenciesFor pkgs;
};

# This is an attempt at building a package independent from nix.
# In order to do so, it changes the library loader for the one
# usually found in `/lib/ld-linux....so`
# Note that this does not change binary rpath, so libraries may still
# be searched in `/nix/store`, but depending on the new ld-linux
# used, it may also fallsback onto more "traditional" (e.g.
# `/usr/lib64`) directories.
# Note that this breaks the run on nixos-system, because
# `/lib/ld-linux...` is not a real library loader.
tsui_no_nix_ld = tsui.overrideAttrs (oldAttrs:
{
# Un-Nix the build so it can dlopen() X11 outside of Nix environments.
preFixup = if pkgs.stdenv.isLinux then ''
patchelf --remove-rpath --set-interpreter ${linuxInterpreter} $out/bin/${pname}
'' else null;
};
});
});

# Add dependencies that are only needed for development
Expand All @@ -89,5 +101,10 @@
# flake provides only one package or there is a clear "main"
# package.
defaultPackage = forAllSystems (system: self.packages.${system}.tsui);

# nix bundle .# creates a file `tsui` in current directory which is a
# self auto-extractable archive which should be self contained and hence
# easy to deploy.
bundles = forAllSystems (system: self.packages.${system}.tsui);
};
}