Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Taken from https://gist.github.com/LnL7/570349866bb69467d0caf5cb175faa74#gistcomment-2931896
self: super:
{
userPackages = super.userPackages or {} // {
# My packages
inherit (self) direnv nix-prefetch-github powershell;
# url = https://github.com/target/lorri/archive/rolling-release.zip;
# git ls-remote https://github.com/target/lorri
lorri = import (super.fetchFromGitHub {
owner = "target";
repo = "lorri";
rev = "d3e452ebc2b24ab86aec18af44c8217b2e469b2a";
sha256 = "07yf3gl9sixh7acxayq4q8h7z4q8a66412z0r49sr69yxb7b4q89";
}) {};
nix-rebuild = super.writeScriptBin "nix-rebuild" ''
#!${super.stdenv.shell}
set -e
if ! command -v nix-env &>/dev/null; then
echo "warning: nix-env was not found in PATH, add nix to userPackages" >&2
PATH=${self.nix}/bin:$PATH
fi
IFS=- read -r _ oldGen _ <<<"$(readlink "$(readlink ~/.nix-profile)")"
oldVersions=$(readlink ~/.nix-profile/package_versions || echo "/dev/null")
nix-env -f '<nixpkgs>' -r -iA userPackages "$@"
IFS=- read -r _ newGen _ <<<"$(readlink "$(readlink ~/.nix-profile)")"
${self.diffutils}/bin/diff --color -u --label "generation $oldGen" $oldVersions \
--label "generation $newGen" ~/.nix-profile/package_versions
'';
packageVersions =
let
versions = super.lib.attrsets.mapAttrsToList (_: pkg: pkg.name) self.userPackages;
versionText = super.lib.strings.concatMapStrings (s: s+"\n") versions;
in
super.writeTextDir "package_versions" versionText;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.