]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Refactor configuration and overlays
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 2 May 2019 10:01:33 +0000 (12:01 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 2 May 2019 10:34:00 +0000 (12:34 +0200)
17 files changed:
config/config.nix [deleted file]
config/overlays.nix [new file with mode: 0644]
default.nix
libs.nix
nixops/custom_nixops.nix [new file with mode: 0644]
nixops/eldiron.nix
nixops/modules/websites/tools/ether/etherpad_lite.nix
nixops/scripts/nixops_wrap
nixops/scripts/pull_deployment
nixops/scripts/push_deployment
nixops/scripts/setup
nixos_tools.nix [deleted file]
overlays/default.nix
overlays/environments/default.nix [new file with mode: 0644]
overlays/environments/immae-eu.nix [new file with mode: 0644]
pkgs/default.nix [moved from overlays/mypkgs.nix with 98% similarity]
scripts/make-env

diff --git a/config/config.nix b/config/config.nix
deleted file mode 100644 (file)
index d6b4714..0000000
+++ /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 (file)
index 0000000..1040d59
--- /dev/null
@@ -0,0 +1 @@
+builtins.attrValues (import ./nixRoot/overlays)
index 9c548a0999b9c6e6996878a3be72704fd85cd8c0..e092c3384cd57646724399d050ecdb9d54c5da56 100644 (file)
-with import <nixpkgs> { 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 <nixpkgs> {} }:
+let
+  pkgs_ = pkgs;
+  mypkgs = import ./pkgs { pkgs = pkgs_; };
+in
+{
+  lib = import ./libs.nix { pkgs = pkgs_; };
+  overlays = import ./overlays;
+  pkgs = mypkgs;
+} // mypkgs
index 981039ec2d1b354e43da3fca3d6f9ce349f44f9b..630b139c2c60238ab81e6d6042e00c5be92f7101 100644 (file)
--- 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 (file)
index 0000000..f024a4d
--- /dev/null
@@ -0,0 +1,2 @@
+with import <nixpkgs> { overlays = builtins.attrValues (import ../overlays); };
+nixops
index 49940411c0b4972fcd42e573981586c8e4671b7a..718d483795274763958a873e41f92e0094649e64 100644 (file)
@@ -11,8 +11,7 @@
     _module.args = {
       pkgsNext = import <nixpkgsNext> {};
       pkgsPrevious = import <nixpkgsPrevious> {};
-      mylibs = import ../libs.nix { nixpkgs = pkgs; };
-      mypkgs = import ../default.nix;
+      mylibs = import ../libs.nix { inherit pkgs; };
       myconfig = {
         inherit privateFiles;
         env = import "${privateFiles}/environment.nix";
index 14ad56507ca08cf6bb0e2e0c0b4173bf3e367b0a..e67497be8e023442c8e2f4b879cfa23573289ab3 100644 (file)
@@ -47,7 +47,7 @@ let
       text =
         # Make sure we’re not rebuilding whole libreoffice just because of a
         # dependency
-        let libreoffice = (import <nixpkgs> {}).libreoffice-fresh;
+        let libreoffice = (import <nixpkgs> { overlays = []; }).libreoffice-fresh;
         in
         ''
           {
index 12f661a30d6adefa3c58477a97979c2af68b1611..d03784e78c3fa575217f6d37a795aca0be72d171 100755 (executable)
@@ -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
index bc4a999f392320a690cc87013d4d98f49ac303f4..10f71feccc5dfabe12d1e8045af0551b10a75589 100755 (executable)
@@ -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"
 
index 067b665522a7f1c1f2881d83e75cab6d5383ed4d..6c67fab805b62d5ed89ef2dea3cd0a6d0222c338 100755 (executable)
@@ -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
index 55dd9d99d883dc5935a15b7c8a0d6da86e032755..1586265d48faae553f7122b81a79e2833f266120 100755 (executable)
@@ -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 (file)
index 0b52e8d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-_:
-with import <nixpkgs/nixos> { configuration = {}; };
-with config.system.build;
-  [ nixos-generate-config nixos-install nixos-enter manual.manpages ]
index ac7e40196ad1520f03504fb708c1f431909ff92d..dcb122e6dd5c3558e9983c654f5fc41b43661df9 100644 (file)
@@ -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 (file)
index 0000000..630b0bd
--- /dev/null
@@ -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 (file)
index 0000000..303ab0f
--- /dev/null
@@ -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" ];
+  };
+}
similarity index 98%
rename from overlays/mypkgs.nix
rename to pkgs/default.nix
index f0bdf95f0dd1875f117f0cbc44373095f1306241..3c09e3076168938c40c04cfe648b8835c4a1e9c7 100644 (file)
@@ -1,4 +1,5 @@
-self: super: with self;
+{ pkgs }:
+with pkgs;
 {
   boinctui = callPackage ../pkgs/boinctui {};
   cnagios = callPackage ../pkgs/cnagios {};
index 415bd5bc9e4681f0a009fdd226c639ed91937413..fc52adc272fb4befc6e7b7a96570ebebb8067cb9 100755 (executable)
@@ -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 "<nixpkgs>" "$@"
+nix-env -r -i -A myEnvironments.immae-eu -f "<nixpkgs>" "$@"