Last active
February 8, 2024 17:00
-
-
Save jbboehr/3a5d0dd52a0c1139ce88b76ab82a9cb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "A very basic flake"; | |
inputs = { | |
ugit-src = { | |
url = "github:Bhupesh-V/ugit"; | |
flake = false; | |
}; | |
flake-utils = { | |
url = "github:numtide/flake-utils"; | |
}; | |
}; | |
outputs = { | |
self, | |
nixpkgs, | |
flake-utils, | |
ugit-src, | |
} @ args: | |
flake-utils.lib.eachDefaultSystem ( | |
system: let | |
pkgs = nixpkgs.legacyPackages.${system}; | |
pkgs' = pkgs; | |
fzf = pkgs.fzf.overrideAttrs (o: | |
o | |
// { | |
# blow away some stuff we don't need | |
postInstall = '' | |
${o.postInstall} | |
rm -rf $out/share | |
rm -rf $out/bin/fzf-tmux | |
rm -rf $out/bin/fzf-share | |
''; | |
}); | |
mkPackages = pkgs: let | |
lib = pkgs.lib; | |
makeWrapper = pkgs.makeWrapper; | |
in rec { | |
busybox = pkgs.busybox.override { | |
#enableMinimal = true; | |
}; | |
git = pkgs.git.override { | |
curl = pkgs.curlMinimal; | |
svnSupport = false; | |
perlSupport = false; | |
nlsSupport = false; | |
osxkeychainSupport = false; | |
guiSupport = false; | |
withManual = false; | |
pythonSupport = false; | |
withpcre2 = false; | |
doInstallCheck = false; | |
withSsh = false; | |
sendEmailSupport = false; | |
}; | |
ncurses = pkgs.ncurses.override { | |
mouseSupport = false; | |
#unicodeSupport = false; | |
}; | |
ugit = pkgs.stdenv.mkDerivation { | |
name = "ugit"; | |
src = ugit-src; | |
nativeBuildInputs = [makeWrapper]; | |
configurePhase = ""; | |
buildPhase = ""; | |
installPhase = '' | |
mkdir -p $out/bin | |
cp $src/ugit $out/bin/ugit | |
chmod +x $out/bin/ugit | |
wrapProgram $out/bin/ugit --set PATH $BIN_PATH | |
''; | |
BIN_PATH = lib.makeBinPath [busybox fzf git ncurses]; | |
}; | |
ugit-docker = pkgs'.dockerTools.buildImage { | |
name = "ugit"; | |
tag = "latest"; | |
created = "now"; | |
copyToRoot = pkgs.buildEnv { | |
name = "image-root"; | |
paths = [ugit busybox git fzf ncurses]; | |
pathsToLink = ["/bin"]; | |
}; | |
config.Cmd = ["/bin/ugit"]; | |
}; | |
}; | |
glibc = mkPackages pkgs; | |
musl = mkPackages pkgs.pkgsMusl; | |
in { | |
packages = rec { | |
ugit-glibc = glibc.ugit; | |
ugit-docker-glibc = glibc.ugit-docker; | |
ugit-musl = musl.ugit; | |
ugit-docker-musl = musl.ugit-docker; | |
default = ugit-glibc; | |
}; | |
formatter = pkgs.alejandra; | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To be clear, I had attempted to use
dockerTools.buildImage
before and was somewhat disappointed in how large the images were, so this was mainly meant as an exercise in optimizing image size using that tool.I do like Nix quite a bit, but don't have much advice outside of the standard sources:
I often refer to
nixpkgs
when developing a derivation.