Alternative Package Manager(s)
Posted: Sun Nov 15, 2015 5:34 pm
Alright since i kept bothering people with Nix/GNU GUIx (GNU Guix is an offshoot of Nix, with all the GNU policy if that's your cup of tea) package manager and blah blah yadda yadda bullshit i talk aloud, and since some people (like sPacE_gaN) is in need for some assistance in installing Krita and the likes (which is currently broken in sid), i'll write a small 'how to for dummies' for you guys:
============================================================================
DISCLAIMER
============================================================================
By installing another package manager alongside the already great apt and some cool wrappers that was built by Bacon and Da Grillaz, you are in risk of bloating your /home or /root dir, symlink hell, lots of hair pulling, thermonuclear war, etc
============================================================================
You could always install other package managers out there (or if you like it super minimal, you could always cross-compile stuff and ask Pidsley how to do it). For the sake of familiarity, this post will guide you thru Nix package manager. I'll refer nix package manager as nix for the rest of this guide.
###########################################################################
Section 1: Installing
###########################################################################
I just copied it and removing the irrelevant stuff for now
###########################################################################
Section 2: Crash Course
###########################################################################
You can always refer to the nix manual
for the sake of brevity, i'll give you a few hints:
Installing stuff:
Searching stuff:
List available channel:
Update repo/channel:
Subscribe to a new channel (for instance stable/unstable channel):
Uninstall stuff:
Upgrade stuff:
Now nix doesn't purge stuff like debian apt do, old version of software will always be kept at /nix/store for when shit hits the fan, you could always rollback to the last known good package. To truly remove it (after you remove the package using nix-env -r) do:
Alright, to rollback first you need to list all generations (nix term for snapshot) available in your machine
then to actually rollback
or
there's an even shorter command, to rollback to previous (exactly one generation behind the current generation)
Okay that's enough for now
###########################################################################
Section 3: Fun stuff begins
###########################################################################
Part 1: Resources for Nix language (the functional language nix package manager use)
nix pills by lethalman
nix manual
Part 2: Creating a new package
Use case example: Frank love wmutils, Frank wanted to install wmutils-opt on his linuxbbq install. Frank could always use git clone, make, make install thingy or create a new debian package. Frank wants more than that, because he's such a bastard. Frank did this instead:
1. Fork nixpkgs repo at https://github.com/nixos/nixpkgs.git
2. Clone it to his local machine
3. Write wmutils expression like this
4. Call wmutils-opt expression on the $FORKED_NIXPKGS_DIR/pkgs/top-level/all-packages.nix
5. Build the installation .drv (nix term for *.o) using this command
6. Frank install it like this
Part 3: Modifying Packages
Use case example: Frank loves bloatful vim. He's such a bastard that he installs vim-tiny on his linuxbbq machine, only to install another vim with luainterp to be able to use neocomplete for his username only. The following are his methods:
1. He creates .nixpkgs dir on his home folder
2. He proceeds to create a config.nix file.
3. This is its content:
#######################################################
Section 4: The Blah Blahs
#######################################################
You could do a lot more in nix, including:
1. Debugging nix expressions using nix-repl
2. Subscribe to multiple channels (combining both nix-stable and nix-unstable for instance)
3. Use your configuration anywhere (your mac, your windows, your BSDs, your other Linux install)
3. Use Emacs and install nix-mode
4. Use Emacs (it's important), install nix-mode, and start hacking the repl
Alright that's pretty much it. Thanks for reading, and don't let anyone stop you from giving obscure shit a try.
EDIT: Adding links
EDIT2: Update some instructions
============================================================================
DISCLAIMER
============================================================================
By installing another package manager alongside the already great apt and some cool wrappers that was built by Bacon and Da Grillaz, you are in risk of bloating your /home or /root dir, symlink hell, lots of hair pulling, thermonuclear war, etc
============================================================================
You could always install other package managers out there (or if you like it super minimal, you could always cross-compile stuff and ask Pidsley how to do it). For the sake of familiarity, this post will guide you thru Nix package manager. I'll refer nix package manager as nix for the rest of this guide.
###########################################################################
Section 1: Installing
###########################################################################
- 1. The safer way: single user install (meaning nix will be installed as the currently logged in user be it root or whatever your username is)
then proceed to add these lines to your .*shrc
Code: Select all
curl https://nixos.org/nix/install | sh
note that this code is usually added automatically when you run the previous command.Code: Select all
if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi
2. The dangerous way: Multi user install
The only available option for this method is install it by source- 1. Grab the source
Make sure your bbq install has build-essential package installed before you proceed
Code: Select all
wget http://nixos.org/releases/nix/nix-1.10/nix-1.10.tar.xz
2. Extract, and run thesefollowed byCode: Select all
./configure --prefix=/usr/local --sysconfdir=/etc
3. Make a new group (name it whatever you like)Code: Select all
make && make install
4. Then we need to add user accounts for each build that gets executed simultaneously, this depends on the number of core(s) available for your processor. For the sake of example, mine is 8 so i do it like this:Code: Select all
sudo groupadd -g 9999 nixjob
5. Making nixjob group legalCode: Select all
for i in `seq 1 8` do sudo useradd -u `expr 9999 + $i` -g nixjob \ -c "Concurrent nix user $i" -d /var/empty -s /noshell done
and do this so /nix/store will be owned by root and the nixjob groupCode: Select all
sudo echo "build-users-group = nixjob" >> /etc/nix/nix.conf
6. Make sure you enable nix daemon at /etc/init.d/nscdCode: Select all
$ sudo chgrp nixjob /nix/store $ sudo chmod 1775 /nix/store
7. Setup user profile directory (for your current user)thenCode: Select all
export NIX_USER_PROFILE_DIR=/nix/var/nix/profiles/per-user/$USER mkdir -m 0755 -p $NIX_USER_PROFILE_DIR if test "$(stat --printf '%u' $NIX_USER_PROFILE_DIR)" != "$(id -u)"; then echo "WARNING: bad ownership on $NIX_USER_PROFILE_DIR" >&2 fi
8. In single user installations, we add the bin directory of the system-wide Nix profile to PATH. In multi-user installations, we have to do this both for the system-wide and the user profile:Code: Select all
if ! test -L $HOME/.nix-profile; then echo "creating $HOME/.nix-profile" >&2 if test "$USER" != root; then ln -s $NIX_USER_PROFILE_DIR/profile $HOME/.nix-profile else # Root installs in the system-wide profile by default. ln -s /nix/var/nix/profiles/default $HOME/.nix-profile fi fi
9. In single user installations, the user can subscribe itself to the Nixpkgs unstable channel. In multi-user installations only root can do this. Ordinary users can still install from the subscribed channels:Code: Select all
export NIX_PROFILES="/nix/var/nix/profiles/default $HOME/.nix-profile" for i in $NIX_PROFILES; do export PATH=$i/bin:$PATH done
10. We have to create a garbage collector root folder for the user:Code: Select all
if [ "$USER" = root -a ! -e $HOME/.nix-channels ]; then echo "http://nixos.org/channels/nixpkgs-unstable nixpkgs" \ > $HOME/.nix-channels fi
11. We must also set the default Nix expression, so that we can conveniently install packages from Nix channels:Code: Select all
NIX_USER_GCROOTS_DIR=/nix/var/nix/gcroots/per-user/$USER mkdir -m 0755 -p $NIX_USER_GCROOTS_DIR if test "$(stat --printf '%u' $NIX_USER_GCROOTS_DIR)" != "$(id -u)"; then echo "WARNING: bad ownership on $NIX_USER_GCROOTS_DIR" >&2 fi
12. Ensure that the unprivileged user can't do shitCode: Select all
if [ ! -e $HOME/.nix-defexpr -o -L $HOME/.nix-defexpr ]; then echo "creating $HOME/.nix-defexpr" >&2 rm -f $HOME/.nix-defexpr mkdir $HOME/.nix-defexpr if [ "$USER" != root ]; then ln -s /nix/var/nix/profiles/per-user/root/channels \ $HOME/.nix-defexpr/channels_root fi fi
13. Shit's cooked, enjoy!Code: Select all
if test "$USER" != root; then export NIX_REMOTE=daemon else export NIX_REMOTE=
- 1. Grab the source
I just copied it and removing the irrelevant stuff for now
###########################################################################
Section 2: Crash Course
###########################################################################
You can always refer to the nix manual
for the sake of brevity, i'll give you a few hints:
Installing stuff:
Code: Select all
nix-env -i $package-name
Code: Select all
nix-env -qaP | grep $package_name
Code: Select all
nix-channel --list
Code: Select all
nix-channel --update
Code: Select all
nix-channel --add $channel_name
Code: Select all
nix-env -e $package_name
Code: Select all
nix-env -u
Code: Select all
nix-collect-garbage -d
Code: Select all
nix-env --list-generations
Code: Select all
nix-env --switch-generation $generation
Code: Select all
nix-env -G $generation
Code: Select all
nix-env --rollback $generation
Okay that's enough for now
###########################################################################
Section 3: Fun stuff begins
###########################################################################
Part 1: Resources for Nix language (the functional language nix package manager use)
nix pills by lethalman
nix manual
Part 2: Creating a new package
Use case example: Frank love wmutils, Frank wanted to install wmutils-opt on his linuxbbq install. Frank could always use git clone, make, make install thingy or create a new debian package. Frank wants more than that, because he's such a bastard. Frank did this instead:
1. Fork nixpkgs repo at https://github.com/nixos/nixpkgs.git
2. Clone it to his local machine
3. Write wmutils expression like this
Code: Select all
{ stdenv, fetchgit, libxcb }:
stdenv.mkDerivation rec {
name = "wmutils-opt-${version}";
version = "2015-08-01";
src = fetchgit {
url = "git://github.com/wmutils/opt.git";
rev = "00fb88f80f2c42cdd664dc678430e77587cd392c";
sha256 = "0938dnx9ql0b91igw9j59grfcjhgn7s31pdvb1ixfs6w4d2g1kcr";
};
buildInputs = [ libxcb ];
installFlags = [ "PREFIX=$(out)" ];
meta = with stdenv.lib; {
description = "optional addons to wmutils";
homepage = https://github.com/wmutils/opt;
license = licenses.isc;
platforms = platforms.unix;
};
}
Code: Select all
wmutils-opt = callPackage ../tools/X11/wmutils-opt { };
Code: Select all
nix-env -f $FORKED_NIXPKGS_LOCATION --build wmutils-opt
Code: Select all
nix-env -f $FORKED_NIXPKGS_LOCATION -i wmutils-opt
Use case example: Frank loves bloatful vim. He's such a bastard that he installs vim-tiny on his linuxbbq machine, only to install another vim with luainterp to be able to use neocomplete for his username only. The following are his methods:
1. He creates .nixpkgs dir on his home folder
2. He proceeds to create a config.nix file.
3. This is its content:
Code: Select all
{
packageOverrides = pkgs: {
vim = pkgs.stdenv.lib.overrideDerivation pkgs.vim_configurable (o: {
name = "myvim";
luaSupport = true;
});
};
}
Section 4: The Blah Blahs
#######################################################
You could do a lot more in nix, including:
1. Debugging nix expressions using nix-repl
2. Subscribe to multiple channels (combining both nix-stable and nix-unstable for instance)
3. Use your configuration anywhere (your mac, your windows, your BSDs, your other Linux install)
3. Use Emacs and install nix-mode
4. Use Emacs (it's important), install nix-mode, and start hacking the repl
Alright that's pretty much it. Thanks for reading, and don't let anyone stop you from giving obscure shit a try.
EDIT: Adding links
EDIT2: Update some instructions