From fdf6f74d3221e3dad853898f296149baea0aa476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Thu, 2 May 2019 12:01:33 +0200 Subject: Refactor configuration and overlays --- config/config.nix | 30 ----- config/overlays.nix | 1 + default.nix | 122 ++------------------- libs.nix | 22 +++- nixops/custom_nixops.nix | 2 + nixops/eldiron.nix | 3 +- .../modules/websites/tools/ether/etherpad_lite.nix | 2 +- nixops/scripts/nixops_wrap | 2 +- nixops/scripts/pull_deployment | 2 +- nixops/scripts/push_deployment | 2 +- nixops/scripts/setup | 2 +- nixos_tools.nix | 4 - overlays/default.nix | 5 +- overlays/environments/default.nix | 3 + overlays/environments/immae-eu.nix | 114 +++++++++++++++++++ overlays/mypkgs.nix | 33 ------ pkgs/default.nix | 34 ++++++ scripts/make-env | 2 +- 18 files changed, 194 insertions(+), 191 deletions(-) delete mode 100644 config/config.nix create mode 100644 config/overlays.nix create mode 100644 nixops/custom_nixops.nix delete mode 100644 nixos_tools.nix create mode 100644 overlays/environments/default.nix create mode 100644 overlays/environments/immae-eu.nix delete mode 100644 overlays/mypkgs.nix create mode 100644 pkgs/default.nix diff --git a/config/config.nix b/config/config.nix deleted file mode 100644 index d6b4714..0000000 --- a/config/config.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - packageOverrides = pkgs: with pkgs; { - # buildEnv is not absolutely equivalent to - # `nix-env -i -f ./nixRoot/default.nix`, see - # https://github.com/NixOS/nix/issues/2682 - immaePackages = pkgs.buildEnv { - name = "Immae-packages"; - paths = builtins.attrValues (import ./nixRoot/default.nix); - pathsToLink = [ "/bin" "/etc" "/include" "/lib" "/libexec" "/share"]; - extraOutputsToInstall = [ "bin" "man" "doc" "info" ]; - }; - # This adds header colors to the builds, but it rebuilds the whole - # world from scratch, so only use it to debug! - # add it as postHook in derivations - immaePostHook = '' - header() { - echo -ne "\033[1;36m" - echo -n "$1" - echo -e "\033[0m" - } - - echoCmd() { - printf "\033[1;34m%s:\033[0m" "$1" - shift - printf ' %q' "$@" - echo - } - ''; - }; -} diff --git a/config/overlays.nix b/config/overlays.nix new file mode 100644 index 0000000..1040d59 --- /dev/null +++ b/config/overlays.nix @@ -0,0 +1 @@ +builtins.attrValues (import ./nixRoot/overlays) diff --git a/default.nix b/default.nix index 9c548a0..e092c33 100644 --- a/default.nix +++ b/default.nix @@ -1,112 +1,10 @@ -with import { overlays = builtins.attrValues (import ./overlays); }; - # https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh - # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks - { # files in overlays/mypkgs.nix - inherit boinctui; - inherit cnagios; - inherit duply; - inherit flrn; - inherit genius; - inherit mtop; - inherit muttprint; - inherit mutt-ics; - inherit nagios-cli; - #inherit nagnu; - inherit note; - inherit notmuch-python2; - inherit notmuch-python3; - inherit notmuch-vim; - inherit pg_activity; - inherit pgloader; - inherit telegram-cli; - inherit telegram-history-dump; - inherit telegramircd; - inherit terminal-velocity; - inherit tiv; - inherit unicodeDoc; - - inherit cardano; - inherit iota-cli-app; - inherit sia; - } // { # overlays - inherit weboob; - inherit taskwarrior; - inherit slrn; - inherit sc-im; - inherit lesspipe; - inherit neomutt; - inherit weechat; - inherit goaccess; - inherit profanity; - inherit nixops; - inherit dwm; - inherit vit; - inherit pass; - inherit elinks; - inherit pelican; - inherit ldapvi; - inherit (mylibs.yarn2nixPackage) yarn2nix; - } // { - inherit nix-prefetch-scripts; - inherit nix-generate-from-cpan; - inherit timewarrior; - inherit pal; - inherit pdftk; - inherit googler; - inherit jrnl; - inherit apg pwgen; - inherit newsboat; - inherit vcsh; - inherit xmr-stak; - inherit urlwatch; - inherit ranger; - inherit irssi; - inherit abook khard khal; - inherit graphicsmagick; - inherit youtube-dl; - inherit ncmpc ncmpcpp; - inherit cadaver; - inherit mairix notmuch; - inherit ctags; - inherit s3cmd; - inherit solc; # solidity - inherit rtorrent; - inherit strace; - inherit vdirsyncer; - inherit w3m lynx links; - inherit gitRepo; - inherit valgrind; - inherit iotop iperf; - inherit keybase; - inherit bogofilter; - inherit mtr; - inherit urlview; - inherit rr; - inherit nix-zsh-completions; - inherit browsh; - inherit monero; - inherit nextcloud-client; - inherit feh imagemagick; - inherit lftp; - stgit = gitAndTools.stgit; - inherit bundix; - bower2nix = nodePackages.bower2nix; - inherit firefox; - inherit jq; - inherit lzo unzip bzip2 p7zip xz; - # unrar is unfree - inherit tig; - inherit emacs26-nox; - inherit highlight sourceHighlight; - pygmentize = python3Packages.pygments; - inherit iftop htop; - inherit fetchmail; - inherit bc; - inherit cpulimit; - inherit dmenu st; - inherit poppler_utils; - inherit tmux; - inherit netcat-gnu; - inherit ledger; - inherit ffmpeg libxslt; - } +{ pkgs ? import {} }: +let + pkgs_ = pkgs; + mypkgs = import ./pkgs { pkgs = pkgs_; }; +in +{ + lib = import ./libs.nix { pkgs = pkgs_; }; + overlays = import ./overlays; + pkgs = mypkgs; +} // mypkgs diff --git a/libs.nix b/libs.nix index 981039e..630b139 100644 --- a/libs.nix +++ b/libs.nix @@ -1,5 +1,5 @@ -{ nixpkgs }: -with nixpkgs; +{ pkgs }: +with pkgs; rec { yarn2nixPackage = let src = fetchFromGitHub { @@ -57,4 +57,22 @@ rec { makeWrapper "$f" "$out" ${toString args} ''; + # This adds header colors to the builds, but it rebuilds the whole + # world from scratch, so only use it to debug! + # add it as postHook in derivations + immaePostHook = '' + header() { + echo -ne "\033[1;36m" + echo -n "$1" + echo -e "\033[0m" + } + + echoCmd() { + printf "\033[1;34m%s:\033[0m" "$1" + shift + printf ' %q' "$@" + echo + } + ''; + } diff --git a/nixops/custom_nixops.nix b/nixops/custom_nixops.nix new file mode 100644 index 0000000..f024a4d --- /dev/null +++ b/nixops/custom_nixops.nix @@ -0,0 +1,2 @@ +with import { overlays = builtins.attrValues (import ../overlays); }; +nixops diff --git a/nixops/eldiron.nix b/nixops/eldiron.nix index 4994041..718d483 100644 --- a/nixops/eldiron.nix +++ b/nixops/eldiron.nix @@ -11,8 +11,7 @@ _module.args = { pkgsNext = import {}; pkgsPrevious = import {}; - mylibs = import ../libs.nix { nixpkgs = pkgs; }; - mypkgs = import ../default.nix; + mylibs = import ../libs.nix { inherit pkgs; }; myconfig = { inherit privateFiles; env = import "${privateFiles}/environment.nix"; diff --git a/nixops/modules/websites/tools/ether/etherpad_lite.nix b/nixops/modules/websites/tools/ether/etherpad_lite.nix index 14ad565..e67497b 100644 --- a/nixops/modules/websites/tools/ether/etherpad_lite.nix +++ b/nixops/modules/websites/tools/ether/etherpad_lite.nix @@ -47,7 +47,7 @@ let text = # Make sure we’re not rebuilding whole libreoffice just because of a # dependency - let libreoffice = (import {}).libreoffice-fresh; + let libreoffice = (import { overlays = []; }).libreoffice-fresh; in '' { diff --git a/nixops/scripts/nixops_wrap b/nixops/scripts/nixops_wrap index 12f661a..d03784e 100755 --- a/nixops/scripts/nixops_wrap +++ b/nixops/scripts/nixops_wrap @@ -9,7 +9,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" export NIXOPS_DEPLOYMENT="$DeploymentUuid" source $(dirname $(dirname $DIR))/nix_path_env -nixops="$(nix-build --no-out-link -A nixops "$(dirname $(dirname $DIR))")/bin/nixops" +nixops="$(nix-build --no-out-link "$(dirname $DIR)/custom_nixops.nix")/bin/nixops" TEMP=$(mktemp -d /tmp/XXXXXX-nixops-files) chmod go-rwx $TEMP diff --git a/nixops/scripts/pull_deployment b/nixops/scripts/pull_deployment index bc4a999..10f71fe 100755 --- a/nixops/scripts/pull_deployment +++ b/nixops/scripts/pull_deployment @@ -9,7 +9,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" export NIXOPS_DEPLOYMENT="$DeploymentUuid" source $(dirname $(dirname $DIR))/nix_path_env -nixops="$(nix-build --no-out-link -A nixops "$(dirname $(dirname $DIR))")/bin/nixops" +nixops="$(nix-build --no-out-link "$(dirname $DIR)/custom_nixops.nix")/bin/nixops" export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" diff --git a/nixops/scripts/push_deployment b/nixops/scripts/push_deployment index 067b665..6c67fab 100755 --- a/nixops/scripts/push_deployment +++ b/nixops/scripts/push_deployment @@ -9,6 +9,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" export NIXOPS_DEPLOYMENT="$DeploymentUuid" source $(dirname $(dirname $DIR))/nix_path_env -nixops="$(nix-build --no-out-link -A nixops "$(dirname $(dirname $DIR))")/bin/nixops" +nixops="$(nix-build --no-out-link "$(dirname $DIR)/custom_nixops.nix")/bin/nixops" $nixops export | pass insert -m $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/Deployment diff --git a/nixops/scripts/setup b/nixops/scripts/setup index 55dd9d9..1586265 100755 --- a/nixops/scripts/setup +++ b/nixops/scripts/setup @@ -136,7 +136,7 @@ fi DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" source $(dirname $(dirname $DIR))/nix_path_env -nixops="$(nix-build --no-out-link -A nixops "$(dirname $(dirname $DIR))")/bin/nixops" +nixops="$(nix-build --no-out-link "$(dirname $DIR)/custom_nixops.nix")/bin/nixops" export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" export NIXOPS_DEPLOYMENT="$DeploymentUuid" diff --git a/nixos_tools.nix b/nixos_tools.nix deleted file mode 100644 index 0b52e8d..0000000 --- a/nixos_tools.nix +++ /dev/null @@ -1,4 +0,0 @@ -_: -with import { configuration = {}; }; -with config.system.build; - [ nixos-generate-config nixos-install nixos-enter manual.manpages ] diff --git a/overlays/default.nix b/overlays/default.nix index ac7e401..dcb122e 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,6 +1,6 @@ { - mylibs = self: super: { mylibs = import ../libs.nix { nixpkgs = self; }; }; - mypkgs = import ./mypkgs.nix; + mylibs = self: super: { mylibs = import ../libs.nix { pkgs = self; }; }; + mypkgs = self: super: import ../pkgs { pkgs = self; }; bitlbee = import ./bitlbee; dwm = import ./dwm; @@ -25,3 +25,4 @@ ympd = import ./ympd; } // import ./python-packages +// import ./environments diff --git a/overlays/environments/default.nix b/overlays/environments/default.nix new file mode 100644 index 0000000..630b0bd --- /dev/null +++ b/overlays/environments/default.nix @@ -0,0 +1,3 @@ +{ + immae-eu = import ./immae-eu.nix; +} diff --git a/overlays/environments/immae-eu.nix b/overlays/environments/immae-eu.nix new file mode 100644 index 0000000..303ab0f --- /dev/null +++ b/overlays/environments/immae-eu.nix @@ -0,0 +1,114 @@ +self: super: with self; +let + # https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh + # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks + paths = [ + # archives + lzo unzip bzip2 p7zip xz + # unrar is unfree + + # backups + duply + + # calendar/contacts + abook khard khal cadaver vdirsyncer pal + + # computing + boinctui + + # cryptocurrencies + cardano sia monero + xmr-stak + solc + iota-cli-app + + # debugging + rr valgrind netcat-gnu strace + + # documentations + unicodeDoc + + # e-mails + muttprint mutt-ics + notmuch-python2 notmuch-python3 notmuch-vim + neomutt mairix notmuch + bogofilter fetchmail + + # git + vcsh gitRepo gitAndTools.stgit tig + + # graphical tools + nextcloud-client firefox + dwm dmenu st + + # images + feh imagemagick tiv graphicsmagick + + # internet browsing + w3m lynx links elinks browsh weboob urlview googler urlwatch + + # less + python3Packages.pygments lesspipe highlight sourceHighlight + + # monitoring + cnagios mtop pg_activity nagios-cli mtr + iftop htop iotop iperf + goaccess + # nagnu + + # messaging/forums/news + flrn slrn + telegram-cli telegram-history-dump telegramircd + weechat profanity + newsboat irssi + + # nix + mylibs.yarn2nixPackage.yarn2nix + nixops nix-prefetch-scripts nix-generate-from-cpan + nix-zsh-completions bundix nodePackages.bower2nix + # (nixos {}).nixos-generate-config + # (nixos {}).nixos-install + # (nixos {}).nixos-enter + # (nixos {}).manual.manpages + + # note taking + note terminal-velocity jrnl + + # office + sc-im ranger + genius bc + ledger + tmux + rtorrent + ldapvi + + # password management + pass apg pwgen + + # pdf + pdftk poppler_utils + + # programming + pelican emacs26-nox ctags + + # security + keybase + + # todolist/time management + taskwarrior vit timewarrior + + # video/music + youtube-dl ncmpc ncmpcpp ffmpeg + + # other tools + pgloader s3cmd lftp jq cpulimit libxslt + ]; +in +{ + myEnvironments.immae-eu = buildEnv { + name = "immae-eu-packages"; + inherit paths; + pathsToLink = [ "/bin" "/etc" "/include" "/lib" "/libexec" "/share"]; + extraOutputsToInstall = [ "bin" "man" "doc" "info" ]; + }; +} diff --git a/overlays/mypkgs.nix b/overlays/mypkgs.nix deleted file mode 100644 index f0bdf95..0000000 --- a/overlays/mypkgs.nix +++ /dev/null @@ -1,33 +0,0 @@ -self: super: with self; -{ - boinctui = callPackage ../pkgs/boinctui {}; - cnagios = callPackage ../pkgs/cnagios {}; - duply = callPackage ../pkgs/duply {}; - flrn = callPackage ../pkgs/flrn { slang = callPackage ../pkgs/slang_1 {}; }; - genius = callPackage ../pkgs/genius {}; - mtop = callPackage ../pkgs/mtop {}; - muttprint = callPackage ../pkgs/muttprint {}; - mutt-ics = callPackage ../pkgs/mutt-ics {}; - nagios-cli = callPackage ../pkgs/nagios-cli {}; - nagnu = callPackage ../pkgs/nagnu {}; - note = callPackage ../pkgs/note {}; - notmuch-python2 = callPackage ../pkgs/notmuch/notmuch-python { pythonPackages = python2Packages; }; - notmuch-python3 = callPackage ../pkgs/notmuch/notmuch-python { pythonPackages = python3Packages; }; - notmuch-vim = callPackage ../pkgs/notmuch/notmuch-vim {}; - pg_activity = callPackage ../pkgs/pg_activity {}; - pgloader = callPackage ../pkgs/pgloader {}; - telegram-cli = callPackage ../pkgs/telegram-cli {}; - telegram-history-dump = callPackage ../pkgs/telegram-history-dump {}; - telegramircd = callPackage ../pkgs/telegramircd { telethon = callPackage ../pkgs/telethon_sync {}; }; - terminal-velocity = callPackage ../pkgs/terminal-velocity {}; - tiv = callPackage ../pkgs/tiv {}; - unicodeDoc = callPackage ../pkgs/unicode {}; - - cardano = callPackage ../pkgs/crypto/cardano {}; - iota-cli-app = callPackage ../pkgs/crypto/iota-cli-app {}; - sia = callPackage ../pkgs/crypto/sia {}; - - pure-ftpd = callPackage ../pkgs/pure-ftpd {}; - mpd = (callPackage ../pkgs/mpd_0_21 {}).mpd; - mpd-small = (callPackage ../pkgs/mpd_0_21 {}).mpd-small; -} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..3c09e30 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,34 @@ +{ pkgs }: +with pkgs; +{ + boinctui = callPackage ../pkgs/boinctui {}; + cnagios = callPackage ../pkgs/cnagios {}; + duply = callPackage ../pkgs/duply {}; + flrn = callPackage ../pkgs/flrn { slang = callPackage ../pkgs/slang_1 {}; }; + genius = callPackage ../pkgs/genius {}; + mtop = callPackage ../pkgs/mtop {}; + muttprint = callPackage ../pkgs/muttprint {}; + mutt-ics = callPackage ../pkgs/mutt-ics {}; + nagios-cli = callPackage ../pkgs/nagios-cli {}; + nagnu = callPackage ../pkgs/nagnu {}; + note = callPackage ../pkgs/note {}; + notmuch-python2 = callPackage ../pkgs/notmuch/notmuch-python { pythonPackages = python2Packages; }; + notmuch-python3 = callPackage ../pkgs/notmuch/notmuch-python { pythonPackages = python3Packages; }; + notmuch-vim = callPackage ../pkgs/notmuch/notmuch-vim {}; + pg_activity = callPackage ../pkgs/pg_activity {}; + pgloader = callPackage ../pkgs/pgloader {}; + telegram-cli = callPackage ../pkgs/telegram-cli {}; + telegram-history-dump = callPackage ../pkgs/telegram-history-dump {}; + telegramircd = callPackage ../pkgs/telegramircd { telethon = callPackage ../pkgs/telethon_sync {}; }; + terminal-velocity = callPackage ../pkgs/terminal-velocity {}; + tiv = callPackage ../pkgs/tiv {}; + unicodeDoc = callPackage ../pkgs/unicode {}; + + cardano = callPackage ../pkgs/crypto/cardano {}; + iota-cli-app = callPackage ../pkgs/crypto/iota-cli-app {}; + sia = callPackage ../pkgs/crypto/sia {}; + + pure-ftpd = callPackage ../pkgs/pure-ftpd {}; + mpd = (callPackage ../pkgs/mpd_0_21 {}).mpd; + mpd-small = (callPackage ../pkgs/mpd_0_21 {}).mpd-small; +} diff --git a/scripts/make-env b/scripts/make-env index 415bd5b..fc52adc 100755 --- a/scripts/make-env +++ b/scripts/make-env @@ -3,4 +3,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" source $(dirname $DIR)/nix_path_env -nix-env -r -i -A immaePackages -f "" "$@" +nix-env -r -i -A myEnvironments.immae-eu -f "" "$@" -- cgit v1.2.3