diff --git a/home.nix b/home.nix index 6041da68..0f20a86a 100644 --- a/home.nix +++ b/home.nix @@ -1,5 +1,5 @@ let - inherit (import { }) lib; + inherit (import (import ./nix/sources.nix).nixpkgs { }) lib; modes = import home/modes.nix; in lib.listToAttrs (lib.flatten (lib.mapAttrsToList (host: configs: lib.mapAttrsToList (mode: config: { diff --git a/home/accounting.nix b/home/accounting.nix index bd01857c..92ae0920 100644 --- a/home/accounting.nix +++ b/home/accounting.nix @@ -1,5 +1,4 @@ -{ ... }: { - home.file.".config/jali/config.py".text = - builtins.readFile ../common/secret/jaliconfig.py; - home.packages = builtins.attrValues (import ../pkgs).accounting-pkgs; +{ pkgs, ... }: { + home.file.".config/jali/config.py".source = ../common/secret/jaliconfig.py; + home.packages = builtins.attrValues pkgs.accounting-pkgs; } diff --git a/home/battery.nix b/home/battery.nix index 1072073a..fbeef866 100644 --- a/home/battery.nix +++ b/home/battery.nix @@ -1,7 +1,6 @@ { lib, pkgs, config, ... }: let - inherit (import ../lib/default.nix) writeHaskellScript; - battery-watch = writeHaskellScript { + battery-watch = pkgs.writeHaskellScript { name = "battery-watch"; libraries = [ pkgs.haskellPackages.fdo-notify diff --git a/home/default.nix b/home/default.nix index 0485dcc8..bcdb83d5 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,21 +1,19 @@ -{ pkgs, config, ... }: +{ pkgs, config, lib, ... }: let inherit (config.m-0.private) me meWork; - inherit (import ../lib) writeHaskellScript; - my-pkgs = import ../pkgs; in { imports = [ ./zsh - ./update-script.nix ./taskwarrior.nix - ./modules/home-options.nix + ./home-options.nix ../common ./unlock.nix ./mpclient.nix ./neovim ]; services.gpg-agent.enable = true; + nixpkgs.overlays = import ../overlays.nix { inherit lib; }; programs = { home-manager.enable = true; @@ -37,7 +35,8 @@ in { package = pkgs.pass-wayland.withExtensions (exts: [ exts.pass-update pkgs.pass-clip ]); enable = true; - settings.PASSWORD_STORE_DIR = "${config.home.homeDirectory}/git/password-store"; + settings.PASSWORD_STORE_DIR = + "${config.home.homeDirectory}/git/password-store"; }; git = { aliases = { sync = "!git pull -r && git push"; }; @@ -134,7 +133,7 @@ in { }; home = { - packages = builtins.attrValues my-pkgs.home-pkgs; + packages = builtins.attrValues pkgs.home-pkgs; sessionVariables = { PATH = "$HOME/.cargo/bin:/etc/profiles/per-user/${config.home.username}/bin:$HOME/.nix-profile/bin:$PATH"; @@ -145,9 +144,7 @@ in { "pass show eu/m-0/${config.m-0.hostName}.m-0.eu/${config.home.username}"; in "${print-pw}/bin/print-pw"; }; - file.".direnvrc".text = '' - source ${my-pkgs.nix-direnv} - ''; + file.".direnvrc".text = "source ${pkgs.sources.nix-direnv}/direnvrc"; }; systemd.user = { startServices = true; }; diff --git a/home/desktop/default.nix b/home/desktop/default.nix index 1a33e406..bb42890e 100644 --- a/home/desktop/default.nix +++ b/home/desktop/default.nix @@ -1,12 +1,11 @@ { pkgs, lib, config, ... }: -let - inherit (import ../../pkgs) desktop-pkgs; - inherit (import ../../lib) colors; +let inherit (import ../../lib) colors; in { - imports = [ ./sleep-nag.nix ./kitty.nix ./wallpaper.nix ./gnome.nix ./firefox.nix ]; + imports = + [ ./sleep-nag.nix ./kitty.nix ./wallpaper.nix ./gnome.nix ./firefox.nix ]; m-0.colors = colors; home = { - packages = builtins.attrValues desktop-pkgs; + packages = builtins.attrValues pkgs.desktop-pkgs; file.".zprofile".text = ". $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"; }; diff --git a/home/desktop/sleep-nag.nix b/home/desktop/sleep-nag.nix index 81bc9bcd..6b52679a 100644 --- a/home/desktop/sleep-nag.nix +++ b/home/desktop/sleep-nag.nix @@ -1,7 +1,6 @@ -{ lib, pkgs, config, ... }: +{ pkgs, ... }: let - inherit (import ../../lib) writeHaskellScript; - sleep-nag = writeHaskellScript { + sleep-nag = pkgs.writeHaskellScript { name = "sleep-nag"; imports = [ "Data.Time.LocalTime" diff --git a/home/desktop/wallpaper.nix b/home/desktop/wallpaper.nix index 24132ed1..a63af0d0 100644 --- a/home/desktop/wallpaper.nix +++ b/home/desktop/wallpaper.nix @@ -1,7 +1,6 @@ -{ lib, pkgs, config, ... }: +{ pkgs, ... }: let - inherit (import ../../lib) writeHaskellScript; - randomWallpaper = writeHaskellScript { + randomWallpaper = pkgs.writeHaskellScript { name = "random-wallpaper"; imports = [ "System.Random" ]; bins = [ pkgs.coreutils pkgs.glib ]; diff --git a/home/games.nix b/home/games.nix index cd5cbc34..a7b7e307 100644 --- a/home/games.nix +++ b/home/games.nix @@ -1,6 +1,5 @@ { pkgs, lib, ... }: -let inherit (import ../lib) unfreePkgs writeHaskellScript; -in { +{ dconf.settings."org/gnome/settings-daemon/plugins/media-keys" = { mic-mute = lib.mkForce [ ]; @@ -50,7 +49,7 @@ in { vulkan-tools ]); runScript = let - gw2wrapper = writeHaskellScript { + gw2wrapper = pkgs.writeHaskellScript { name = "gw2wrapper"; bins = [ pkgs.procps ]; imports = [ "System.Directory (withCurrentDirectory)" ]; diff --git a/home/home-options.nix b/home/home-options.nix new file mode 100644 index 00000000..5493f662 --- /dev/null +++ b/home/home-options.nix @@ -0,0 +1,17 @@ +{ lib, ... }: { + + options = { + m-0 = { + hostName = lib.mkOption { type = lib.types.str; }; + terminal = lib.mkOption { + default = "kitty"; + type = lib.types.str; + }; + colors = lib.mkOption { + default = { }; + type = lib.types.attrs; + }; + }; + }; + +} diff --git a/home/laptop.nix b/home/laptop.nix index 9c421f54..6f4aab2e 100644 --- a/home/laptop.nix +++ b/home/laptop.nix @@ -1,6 +1,5 @@ { pkgs, lib, ... }: let - inherit (import ../lib) writeHaskellScript; modes = pkgs.lib.attrNames (import ./modes.nix).apollo; autostart-script = pkgs.writeShellScriptBin "home-manager-autostart" '' ${pkgs.xorg.xrdb}/bin/xrdb ${builtins.toFile "Xresources" "Xft.dpi: 96"} @@ -24,7 +23,7 @@ in { sudo -A nix-collect-garbage -d sudo -A nix optimise-store ''; - activateMode = writeHaskellScript { name = "activate-mode"; } '' + activateMode = pkgs.writeHaskellScript { name = "activate-mode"; } '' getMode :: IO Text getMode = decodeUtf8 <$> (cat "/home/maralorn/volatile/mode" |> captureTrim) @@ -34,7 +33,7 @@ in { exe ([i|/home/maralorn/.modes/#{mode}/activate|] :: String) exe "random-wallpaper" ''; - updateModes = writeHaskellScript { + updateModes = pkgs.writeHaskellScript { name = "update-modes"; bins = [ activateMode ]; } '' diff --git a/home/mail.nix b/home/mail.nix index 06bcbc3c..ab719fa0 100644 --- a/home/mail.nix +++ b/home/mail.nix @@ -1,6 +1,5 @@ { lib, config, pkgs, ... }: let - inherit (import ../lib) writeHaskellScript; inherit (config.m-0.private) sendmail me; inherit (config.m-0.private.mail_filters) sortLists stupidLists notifications; maildir = config.accounts.email.maildirBasePath; @@ -25,7 +24,7 @@ let myFilters = builtins.map filter.simpleSortList sortLists ++ builtins.map filter.stupidList stupidLists ++ builtins.map filter.notifications notifications; - sortMail = writeHaskellScript { + sortMail = pkgs.writeHaskellScript { name = "sort-mail-archive"; bins = [ pkgs.notmuch pkgs.coreutils pkgs.mblaze pkgs.findutils ]; libraries = [ pkgs.haskellPackages.megaparsec ]; diff --git a/home/modes.nix b/home/modes.nix index b0aef998..29fd55b1 100644 --- a/home/modes.nix +++ b/home/modes.nix @@ -1,5 +1,5 @@ let - inherit (import { }) lib; + inherit (import (import ../nix/sources.nix).nixpkgs { }) lib; makeConfig = hostName: imports: { ... }: { imports = imports ++ [ ./default.nix ]; @@ -90,7 +90,6 @@ in { tinkering = apolloConfig [ ./mail-client.nix - ./update-script.nix ./tinkering.nix ./chat.nix (makeBlock leisurePages) diff --git a/home/modules/bugwarrior.nix b/home/modules/bugwarrior.nix deleted file mode 100644 index 6809baf7..00000000 --- a/home/modules/bugwarrior.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; -let inherit (config.m-0.private) me gitlab github otrs; -in { - options.m-0.bugwarrior.enable = - mkEnableOption "Sync tasks from issuetrackers"; - config = mkIf config.m-0.bugwarrior.enable { - home.file.".config/bugwarrior/bugwarriorrc".text = '' - [general] - targets=cda_gitlab,github - static_fields = priority, project - - [cda_gitlab] - service=gitlab - gitlab.password=@oracle:eval:pass de/darmstadt/ccc/ldap - gitlab.login=${me.user} - gitlab.host=${gitlab.host} - gitlab.token=${gitlab.token} - gitlab.only_if_assigned=${me.user} - gitlab.also_unassigned=True - gitlab.default_priority= L - gitlab.include_repos=cda/tasks, cda/chaos-darmstadt.de, cda/doku - gitlab.include_regex=(vorstand|jali|${me.user})/.*, - gitlab.description_template = {{gitlabnamespace}}/{{gitlabrepo}} {{gitlabtype[:1]}}#{{gitlabnumber}}: {{gitlabtitle}} - gitlab.project_template = - - [github] - service=github - github.login = ${me.user} - github.username = ${me.user} - github.token = ${github.token} - github.description_template = {{githubrepo}} {{githubtype[:1]}}#{{githubnumber}}: {{githubtitle}} - github.include_user_issues = False - github.include_user_repos = False - github.query = is:open involves:maralorn archived:false -repo:maxtaco/coffee-script -repo:QMatrixClient/libqmatrixclient -repo:QMatrixClient/Quaternion -repo:trollhoehle/pythonlights -repo:MirakelX/mirakel-android - github.default_priority= L - github.project_template = - ''; - systemd.user = { - services.bugwarrior = { - Unit = { Description = "Run bugwarrior"; }; - Service = { - Type = "oneshot"; - Environment = - "PATH=${pkgs.taskwarrior}/bin:${pkgs.eventd}/bin:${pkgs.gnugrep}/bin"; - ExecStart = "${pkgs.bugwarrior}/bin/bugwarrior-pull"; - }; - }; - timers.bugwarrior = { - Timer = { OnCalendar = "hourly"; }; - Install = { WantedBy = [ "timers.target" ]; }; - }; - }; - }; - -} diff --git a/home/modules/force-copies.nix b/home/modules/force-copies.nix deleted file mode 100644 index 1295c6a5..00000000 --- a/home/modules/force-copies.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ lib, config, ... }: -let - paths = config.home.forceCopies.paths; - disableCollisionCheck = path: '' - if [[ -a $HOME/${path} ]]; then - echo "Removing $HOME/${path}" because it is probably from a previous generation. - rm -f $HOME/${path} - fi - ''; - copyPath = path: '' - canonical=`readlink -f $newGenPath/home-files/${path}` - if [[ ! -a $canonical ]]; then - echo "File $newGenPath/home-files/${path} does not exist." - exit 1 - fi - if [[ ! -a $HOME/${path} ]]; then - echo "There is no file at $HOME/${path} this is weird." - exit 1 - fi - echo "Overwriting $HOME/${path}" - cp --remove-destination -T $canonical $HOME/${path}; - ''; -in with lib; { - options.home.forceCopies.paths = mkOption { - default = [ ]; - type = types.listOf types.str; - }; - config.home.activation = { - deleteForcedCopies = config.lib.dag.entryBefore [ "checkLinkTargets" ] - (builtins.concatStringsSep "\n" - (builtins.map disableCollisionCheck paths)); - forceCopies = config.lib.dag.entryAfter [ "linkGeneration" ] - (builtins.concatStringsSep "\n" (builtins.map copyPath paths)); - }; -} diff --git a/home/modules/home-options.nix b/home/modules/home-options.nix deleted file mode 100644 index 872831ee..00000000 --- a/home/modules/home-options.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ lib, config, pkgs, ... }: -with lib; { - - options = { - m-0 = { - hostName = mkOption { type = types.str; }; - terminal = mkOption { - default = "urxvt"; - type = types.str; - }; - colors = mkOption { - default = { }; - type = types.attrs; - }; - workspaces = mkOption { - default = [ "configure some workspaces" ]; - type = types.listOf types.str; - }; - }; - }; - -} diff --git a/home/on-foreign-machine.nix b/home/on-foreign-machine.nix deleted file mode 100644 index 58de4ae3..00000000 --- a/home/on-foreign-machine.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ pkgs, config, lib, ... }: -let inherit (import ../lib) writeHaskellScript sources; -in { - home = { - packages = builtins.attrValues (import ../pkgs).foreign-home-pkgs; - sessionVariables = { NIX_PATH = "$HOME/.nix-path"; }; - file = { - home-manager-source = { - target = ".nix-path/home-manager"; - source = sources.home-manager; - }; - nixpkgsr-source = { - target = ".nix-path/nixpkgs"; - source = sources.nixpkgs; - }; - nixos = { - target = ".nix-path/nixos"; - source = sources.nixpkgs; - }; - unstable = { - target = ".nix-path/unstable"; - source = sources.unstable; - }; - }; - }; -} diff --git a/home/on-my-machine.nix b/home/on-my-machine.nix index a317a975..776e1464 100644 --- a/home/on-my-machine.nix +++ b/home/on-my-machine.nix @@ -2,6 +2,6 @@ home = { username = "maralorn"; homeDirectory = "/home/maralorn"; - packages = builtins.attrValues (import ../pkgs).my-home-pkgs; + packages = builtins.attrValues pkgs.my-home-pkgs; }; } diff --git a/home/target.nix b/home/target.nix index bc9a0661..60ca5426 100644 --- a/home/target.nix +++ b/home/target.nix @@ -1,5 +1,5 @@ let - inherit (import { }) lib pkgs; + inherit (import (import ../nix/sources.nix).nixpkgs { }) lib pkgs; modes = import ./modes.nix; home-manager = import ; buildHomeManager = attr: diff --git a/home/taskwarrior.nix b/home/taskwarrior.nix index 2270d88c..169c95d3 100644 --- a/home/taskwarrior.nix +++ b/home/taskwarrior.nix @@ -28,7 +28,7 @@ Bool a -> show a Null -> "null" ''; - inherit (import ../lib) writeHaskellScript; + inherit (pkgs) writeHaskellScript; libraries = [ pkgs.haskellPackages.fdo-notify pkgs.haskellPackages.aeson diff --git a/home/tinkering.nix b/home/tinkering.nix index 4f339764..a488a20f 100644 --- a/home/tinkering.nix +++ b/home/tinkering.nix @@ -2,7 +2,8 @@ home.packages = builtins.attrValues { inherit (pkgs.xorg) xev; inherit (pkgs.gitAndTools) hub; - inherit (pkgs) meld icedtea8_web octave filezilla cachix nix-review gparted; - grafana-devel = pkgs.callPackage ../pkgs/grafana-devel.nix { }; + inherit (pkgs) + meld icedtea8_web octave filezilla cachix nix-review gparted + grafana-devel; }; } diff --git a/home/update-script.nix b/home/update-script.nix deleted file mode 100644 index 59cd85bc..00000000 --- a/home/update-script.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ pkgs, config, lib, ... }: -let - inherit (import ../lib) writeHaskellScript get-niv-path gcRetentionDays; - inherit (import ../lib/update-home.nix) update-home; - configPath = "/home/${config.home.username}/git/config"; -in { - home = { - packages = builtins.attrValues { - inherit get-niv-path; - update-home = update-home configPath; - }; - }; -} diff --git a/hosts/hephaistos/bootstrap-bin/proot b/hosts/hephaistos/bootstrap-bin/proot deleted file mode 100755 index 17a6a091..00000000 Binary files a/hosts/hephaistos/bootstrap-bin/proot and /dev/null differ diff --git a/hosts/hephaistos/bootstrap-bin/run-in-nix b/hosts/hephaistos/bootstrap-bin/run-in-nix deleted file mode 100755 index dc15e516..00000000 --- a/hosts/hephaistos/bootstrap-bin/run-in-nix +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. ~/.nix-profile/etc/profile.d/nix.sh -. ~/.nix-profile/etc/profile.d/hm-session-vars.sh -exec "$@" diff --git a/hosts/hephaistos/bootstrap-bin/with-nix b/hosts/hephaistos/bootstrap-bin/with-nix deleted file mode 100755 index 4c478abd..00000000 --- a/hosts/hephaistos/bootstrap-bin/with-nix +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec ~/bin/proot -b ~/.nix:/nix bin/run-in-nix $@ diff --git a/hosts/hephaistos/home.nix b/hosts/hephaistos/home.nix deleted file mode 100644 index d8d2e9c9..00000000 --- a/hosts/hephaistos/home.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ pkgs, config, ... }: { - imports = [ ../../home ../../home/on-foreign-machine.nix ]; - - systemd.user.systemctlPath = "/usr/bin/systemctl"; - - m-0 = { hostName = "fb04217"; }; - - home = { - username = "brandy"; - homeDirectory = "/home/brandy"; - language = { - base = "C.UTF-8"; - address = "C.UTF-8"; - monetary = "C.UTF-8"; - paper = "C.UTF-8"; - time = "C.UTF-8"; - }; - sessionVariables = { - LANGUAGE = "en_US"; - LC_CTYPE = "C.UTF-8"; - LC_NUMERIC = "C.UTF-8"; - LC_COLLATE = "C.UTF-8"; - LC_MESSAGES = "C.UTF-8"; - LC_NAME = "C.UTF-8"; - LC_TELEPHONE = "C.UTF-8"; - LC_MEASUREMENT = "C.UTF-8"; - LC_IDENTIFICATION = "C.UTF-8"; - }; - forceCopies.paths = - [ "bin/proot" "bin/with-nix" "bin/run-in-nix" ".bashrc" ".zshrc" ]; - file = { - ".bashrc".text = '' - [ -z "$PS1" ] && return - unset __HM_SESS_VARS_SOURCED - if [[ -z "$NIX_PATH" ]] - then - exec ~/bin/with-nix zsh - else - exec zsh - fi - ''; - "bin" = { - source = ./bootstrap-bin; - recursive = true; - }; - }; - - packages = [ - (pkgs.writeShellScriptBin "maintenance" '' - set -e - cd ~/git/nixos/nixpkgs - git checkout nixos-local - git pull --no-edit upstream nixos-19.03 - git pull --no-edit origin nixos-maralorn - cd ~/git/nixos/home-manager - git checkout home-manager-local - git pull --no-edit upstream release-19.03 - git pull --no-edit origin home-manager-maralorn - home-manager switch - nix-collect-garbage --delete-older-than 5d - nix-store --optimise - '') - ]; - }; - -} diff --git a/hosts/hephaistos/nix-gc.nix b/hosts/hephaistos/nix-gc.nix deleted file mode 100644 index 563da27b..00000000 --- a/hosts/hephaistos/nix-gc.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ pkgs, ... }: { - systemd.user = { - services.nix-gc = { - Unit = { Description = "Collect garbage"; }; - - Service = { - Type = "oneshot"; - ExecStart = - "${pkgs.nix}/bin/nix-collect-garbage --delete-older-than 5d"; - }; - }; - timers.nix-gc = { - Timer = { - OnCalendar = "22:00"; - Persistent = "true"; - }; - }; - }; -} diff --git a/hosts/hephaistos/nix-update-channel.nix b/hosts/hephaistos/nix-update-channel.nix deleted file mode 100644 index ddf6c849..00000000 --- a/hosts/hephaistos/nix-update-channel.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ pkgs, ... }: { - systemd.user = { - services.nix-update = { - Unit = { Description = "Update nix-channel"; }; - - Service = { - Type = "oneshot"; - ExecStart = "${pkgs.nix}/bin/nix-channel --update"; - }; - }; - timers.nix-update = { - Timer = { - OnCalendar = "22:00"; - Persistent = "true"; - }; - }; - }; -} diff --git a/hosts/hephaistos/syncthing.nix b/hosts/hephaistos/syncthing.nix deleted file mode 100644 index 5526fdcc..00000000 --- a/hosts/hephaistos/syncthing.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ pkgs, ... }: { - systemd.user = { - services.syncthing = { - Unit = { - Description = "Syncthing"; - ConditionHost = "fb04217"; - Wants = "syncthing-inotify.service"; - }; - - Service = { - ExecStart = - "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"; - Restart = "on-failure"; - SuccessExitStatus = "3 4"; - RestartForceExitStatus = "3 4"; - }; - }; - }; -} diff --git a/lib/default.nix b/lib/default.nix index a21395f3..3c9021a1 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -19,79 +19,4 @@ rec { "white" = "#dddbff"; "brightWhite" = "#ffffff"; }; - pkgs = import { }; - haskellList = list: ''["${builtins.concatStringsSep ''", "'' list}"]''; - writeHaskellScript = - { name ? "haskell-script", bins ? [ ], libraries ? [ ], imports ? [ ] }: - code: - pkgs.writers.makeBinWriter { - compileScript = '' - cp $contentPath ${name}.hs - ${ - pkgs.ghc.withPackages (_: - libraries ++ (builtins.attrValues { - inherit (pkgs.haskellPackages) - shh string-interpolate relude async say cmdargs text; - })) - }/bin/ghc ${name}.hs -threaded -Wall -Wno-unused-top-binds -Wno-missing-signatures -Wno-type-defaults -Wno-unused-imports -Werror - mv ${name} $out - ${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded "$out" - ''; - } "/bin/${name}" '' - {-# LANGUAGE DeriveDataTypeable #-} - {-# LANGUAGE TemplateHaskell #-} - {-# LANGUAGE QuasiQuotes #-} - {-# LANGUAGE OverloadedStrings #-} - {-# LANGUAGE ExtendedDefaultRules #-} - {-# LANGUAGE MultiWayIf #-} - {-# LANGUAGE LambdaCase #-} - {-# LANGUAGE ViewPatterns #-} - {-# LANGUAGE ScopedTypeVariables #-} - {-# LANGUAGE NoImplicitPrelude #-} - {-# LANGUAGE TupleSections #-} - - import Shh - import Relude - import Say - import qualified Relude.Unsafe as Unsafe - import qualified Data.ByteString.Lazy as LBS - import qualified Data.ByteString as BS - import qualified Data.Text as Text - import System.Environment (getArgs) - import Control.Exception (bracket, try) - import Data.String.Interpolate (i) - import Control.Concurrent.Async - ${builtins.concatStringsSep "\n" (map (x: "import ${x}") imports)} - - -- Load binaries from Nix packages. The dependencies will be captured - -- in the closure. - loadFromBins (${ - haskellList - (builtins.map toString (bins ++ [ pkgs.coreutils pkgs.nix ])) - } :: [String]) - - getNivPath :: Text -> Text -> IO Text - getNivPath sources channel = do - let expression = [i|(import #{sources}/nix/sources.nix).#{channel}|] :: String - nix_build ["-Q", "-E", expression, "--no-out-link"] &> devNull - escaped <- nix_instantiate ["--eval" :: String, "-E", [i|toString #{expression}|]] |> captureTrim - pure . Text.dropAround ('"' ==) . decodeUtf8 . trim $ escaped - - myNixPath :: Text -> IO [String] - myNixPath path = (extraPaths ++) . concat <$> mapM getNivAssign ["home-manager", "nixpkgs", "unstable"] - where - tag name str = ["-I", [i|#{name :: Text}=#{str :: Text}|]] :: [String] - getNivAssign name = tag name <$> getNivPath path name - extraPaths = ["-I", [i|nixpkgs-overlays=#{path}/overlays|]] - - main :: IO () - ${code} - ''; - get-niv-path = writeHaskellScript { name = "get-niv-path"; } '' - main = do - [sources, channel] <- fmap toText <$> getArgs - path <- getNivPath sources channel - say path - ''; - home-manager = pkgs.callPackage { }; } diff --git a/lib/update-home.nix b/lib/update-home.nix deleted file mode 100644 index 04f4124d..00000000 --- a/lib/update-home.nix +++ /dev/null @@ -1,13 +0,0 @@ -let inherit (import ./.) home-manager writeHaskellScript; -in { - update-home = configPath: - writeHaskellScript { - name = "update-home"; - bins = [ home-manager ]; - } '' - main = do - args <- getArgs - paths <- myNixPath "${configPath}" - home_manager $ paths ++ ["switch"] ++ fmap toString args - ''; -} diff --git a/lib/update-system.nix b/lib/update-system.nix index e7cbbf5e..8b3a1ef7 100644 --- a/lib/update-system.nix +++ b/lib/update-system.nix @@ -1,8 +1,7 @@ -nixos-rebuild: -let inherit (import ../lib) writeHaskellScript; -in rec { - configPath = "/etc/nixos"; - update-system = writeHaskellScript { +{ pkgs, nixos-rebuild }: +let configPath = "/etc/nixos"; +in { + update-system = pkgs.writeHaskellScript { name = "update-system"; bins = [ nixos-rebuild ]; } '' diff --git a/overlays.nix b/overlays.nix new file mode 100644 index 00000000..787067b2 --- /dev/null +++ b/overlays.nix @@ -0,0 +1,11 @@ +{ lib }: +let + overlayPath = ./overlays; + candidates = lib.attrNames (builtins.readDir overlayPath); + pathToOverlay = n: overlayPath + ("/" + n); + isNixFile = n: builtins.match ".*\\.nix" n != null; + isNixDir = n: builtins.pathExists (pathToOverlay n + "/default.nix"); + isOverlay = n: isNixDir n || isNixFile n; + overlays = builtins.filter isOverlay candidates; + importOverlay = n: import (pathToOverlay n); +in map importOverlay overlays diff --git a/overlays/sources.nix b/overlays/00-sources.nix similarity index 100% rename from overlays/sources.nix rename to overlays/00-sources.nix diff --git a/overlays/1-unfree.nix b/overlays/1-unfree.nix deleted file mode 100644 index c0ad9a92..00000000 --- a/overlays/1-unfree.nix +++ /dev/null @@ -1,6 +0,0 @@ -self: super: -if super.config.allowUnfree or false then - { } -else { - unfree = import { config.allowUnfree = true; }; -} diff --git a/overlays/0-previews.nix b/overlays/10-previews.nix similarity index 90% rename from overlays/0-previews.nix rename to overlays/10-previews.nix index dc555632..75e289a1 100644 --- a/overlays/0-previews.nix +++ b/overlays/10-previews.nix @@ -2,7 +2,7 @@ self: super: let preview = version: func: if super.lib.versionOlder super.lib.version version then - func (import { }) + func (import self.sources.unstable { }) else { }; in preview "20.09pre-git" (unstable: { diff --git a/overlays/20-unfree.nix b/overlays/20-unfree.nix new file mode 100644 index 00000000..01b127fa --- /dev/null +++ b/overlays/20-unfree.nix @@ -0,0 +1,6 @@ +self: super: +if super.config.allowUnfree or false then + { } +else { + unfree = import self.sources.nixpkgs { config.allowUnfree = true; }; +} diff --git a/overlays/grafana-devel/default.nix b/overlays/grafana-devel/default.nix new file mode 100644 index 00000000..6b2db2ee --- /dev/null +++ b/overlays/grafana-devel/default.nix @@ -0,0 +1 @@ +self: super: { grafana-devel = self.callPackage ./package.nix { }; } diff --git a/pkgs/grafana-devel.nix b/overlays/grafana-devel/package.nix similarity index 97% rename from pkgs/grafana-devel.nix rename to overlays/grafana-devel/package.nix index 0ff2ffbe..7458171a 100644 --- a/pkgs/grafana-devel.nix +++ b/overlays/grafana-devel/package.nix @@ -12,7 +12,7 @@ let providers = [{ name = "Static dashboards"; folder = ""; - options.path = ../system/monitoring/grafana-dashboards; + options.path = ../../system/monitoring/grafana-dashboards; orgId = 1; type = "file"; updateIntervalSeconds = 60; diff --git a/overlays/pkgSets.nix b/overlays/pkgSets.nix new file mode 100644 index 00000000..aee88455 --- /dev/null +++ b/overlays/pkgSets.nix @@ -0,0 +1,52 @@ +self: super: { + # pkgs assumed to be present on a non nixos host + core-system-pkgs = { + inherit (self) + gitFull gnumake mkpasswd file wget curl wireguard gnupg mutt bind liboping + psmisc unzip rename whois lsof parted python3 binutils ntfsprogs neovim; + }; + + extra-system-pkgs = { + inherit (self.python3Packages) qrcode; + inherit (self) + git-crypt htop tree pwgen borgbackup inotifyTools direnv socat nmap ncdu + tcpdump tmux tig exa fzf ag fd bat ripgrep ranger pass sshuttle vnstat + entr libargon2 mblaze niv; + }; + + my-home-pkgs = { + print215 = self.writeShellScriptBin "print215" '' + scp "$@" ag-forward: + ssh ag-forward lpr -Zduplex -r "$@" + ''; + print215single = self.writeShellScriptBin "print215single" '' + scp "$@" ag-forward: + ssh ag-forward lpr -r "$@" + ''; + }; + desktop-pkgs = { + inherit (self) lm_sensors xwayland xdg_utils libnotify; + inherit (self.gnomeExtensions) appindicator system-monitor; + inherit (self.gnome3) + dconf dconf-editor gnome-tweaks gnome-shell-extensions adwaita-icon-theme + gnome-session; + }; + home-pkgs = { + inherit (self.pythonPackages) yapf jsbeautifier; + inherit (self.haskellPackages) brittany ormolu releaser; + inherit (self) + go gdb mpc_cli ncmpcpp shfmt htmlTidy astyle nodejs tasksh magic-wormhole + nixfmt stack ghcid rnix-lsp tmate rustup kitty ghc cabal-install; + obelisk = (import self.sources.obelisk { }).command; + }; + accounting-pkgs = { + inherit (self.haskellPackages) hledger hledger-ui hledger-web; + inherit (self) ledger jali; + }; + system-pkgs = self.core-system-pkgs // self.extra-system-pkgs // { + inherit (self) test-system-config test-home-config test-config; + home-manager = + self.callPackage "${self.sources.home-manager}/home-manager" { }; + }; + foreign-home-pkgs = self.extra-system-pkgs; +} diff --git a/lib/test.nix b/overlays/testing.nix similarity index 80% rename from lib/test.nix rename to overlays/testing.nix index c2ee32e2..587ab29e 100644 --- a/lib/test.nix +++ b/overlays/testing.nix @@ -1,7 +1,12 @@ +self: super: let - inherit (import ../lib) - pkgs writeHaskellScript home-manager unstable haskellList; -in rec { + bins = [ self.nix ]; + imports = [ "System.IO (hFlush)" ]; + repoSrc = "git@hera.m-0.eu:nixos-config"; + configPath = "/etc/nixos"; + systems = [ "apollo" "hera" ]; + homes = self.lib.attrNames (import ../home/modes.nix); + keys = [ "default" "apollo" "hera" ]; haskellBody = name: commandline: '' main = do (configDir:hostname:args) <- getArgs @@ -11,10 +16,9 @@ in rec { ${commandline} say [i|Build of ${name} config for #{hostname} was successful.|] ''; - bins = [ pkgs.nix ]; - imports = [ "System.IO (hFlush)" ]; +in { - test-system-config = writeHaskellScript { + test-system-config = self.writeHaskellScript { name = "test-system-config"; inherit bins; inherit imports; @@ -22,7 +26,7 @@ in rec { nix_build $ ["", "-A", "system"] ++ paths ++ ["-I", [i|nixos-config=#{configDir}/hosts/#{hostname}/configuration.nix|], "-o", [i|result-system-#{hostname}|]] ++ fmap toString args ''); - test-home-config = writeHaskellScript { + test-home-config = self.writeHaskellScript { name = "test-home-config"; inherit bins; inherit imports; @@ -30,15 +34,10 @@ in rec { nix_build $ paths ++ [[i|#{configDir}/home/target.nix|], "-A", hostname, "-o", [i|result-home-manager-#{hostname}|]] ++ fmap toString args ''); - repoSrc = "git@hera.m-0.eu:nixos-config"; - configPath = "/etc/nixos"; - systems = [ "apollo" "hera" ]; - homes = pkgs.lib.attrNames (import ../home/modes.nix); - keys = [ "default" "apollo" "hera" ]; - test-config = writeHaskellScript { + test-config = self.writeHaskellScript { name = "test-config"; bins = - [ test-system-config test-home-config pkgs.git pkgs.niv pkgs.git-crypt ]; + [ self.test-system-config self.test-home-config self.git self.niv self.git-crypt ]; imports = [ "System.Directory (withCurrentDirectory)" ]; } '' checkout :: IO FilePath @@ -52,7 +51,7 @@ in rec { bracket checkout (rm "-rf") $ \repoDir -> do withCurrentDirectory repoDir $ do mapM_ (\x -> git_crypt "unlock" ([i|${configPath}/.git/git-crypt/keys/#{x}|] :: String)) ${ - haskellList keys + self.haskellList keys } when bump $ ignoreFailure $ niv "update" changed <- (mempty /=) <$> (git "-C" repoDir "status" "--porcelain" |> captureTrim) @@ -61,8 +60,8 @@ in rec { git "-C" repoDir "config" "user.name" "maralorn (nix-auto-updater)" git "-C" repoDir "commit" "-am" "Update dependencies with niv" git "-C" repoDir "push" "-f" "origin" "master:version-bump" - mapM_ (test_system_config repoDir) ${haskellList systems} - mapM_ (test_home_config repoDir) ${haskellList homes} + mapM_ (test_system_config repoDir) ${self.haskellList systems} + mapM_ (test_home_config repoDir) ${self.haskellList homes} when changed $ do git "-C" repoDir "push" "origin" "master:master" ''; diff --git a/overlays/writeHaskellScript.nix b/overlays/writeHaskellScript.nix new file mode 100644 index 00000000..35490760 --- /dev/null +++ b/overlays/writeHaskellScript.nix @@ -0,0 +1,74 @@ +self: super: { + haskellList = list: ''["${builtins.concatStringsSep ''", "'' list}"]''; + writeHaskellScript = + { name ? "haskell-script", bins ? [ ], libraries ? [ ], imports ? [ ] }: + code: + self.writers.makeBinWriter { + compileScript = '' + cp $contentPath ${name}.hs + ${ + self.ghc.withPackages (_: + libraries ++ (builtins.attrValues { + inherit (self.haskellPackages) + shh string-interpolate relude async say cmdargs text; + })) + }/bin/ghc ${name}.hs -threaded -Wall -Wno-unused-top-binds -Wno-missing-signatures -Wno-type-defaults -Wno-unused-imports -Werror + mv ${name} $out + ${self.binutils-unwrapped}/bin/strip --strip-unneeded "$out" + ''; + } "/bin/${name}" '' + {-# LANGUAGE DeriveDataTypeable #-} + {-# LANGUAGE TemplateHaskell #-} + {-# LANGUAGE QuasiQuotes #-} + {-# LANGUAGE OverloadedStrings #-} + {-# LANGUAGE ExtendedDefaultRules #-} + {-# LANGUAGE MultiWayIf #-} + {-# LANGUAGE LambdaCase #-} + {-# LANGUAGE ViewPatterns #-} + {-# LANGUAGE ScopedTypeVariables #-} + {-# LANGUAGE NoImplicitPrelude #-} + {-# LANGUAGE TupleSections #-} + + import Shh + import Relude + import Say + import qualified Relude.Unsafe as Unsafe + import qualified Data.ByteString.Lazy as LBS + import qualified Data.ByteString as BS + import qualified Data.Text as Text + import System.Environment (getArgs) + import Control.Exception (bracket, try) + import Data.String.Interpolate (i) + import Control.Concurrent.Async + ${builtins.concatStringsSep "\n" (map (x: "import ${x}") imports)} + + -- Load binaries from Nix packages. The dependencies will be captured + -- in the closure. + loadFromBins (${ + self.haskellList + (builtins.map toString (bins ++ [ self.coreutils self.nix ])) + } :: [String]) + + getNivPath :: Text -> Text -> IO Text + getNivPath sources channel = do + let expression = [i|(import #{sources}/nix/sources.nix).#{channel}|] :: String + nix_build ["-Q", "-E", expression, "--no-out-link"] &> devNull + escaped <- nix_instantiate ["--eval" :: String, "-E", [i|toString #{expression}|]] |> captureTrim + pure . Text.dropAround ('"' ==) . decodeUtf8 . trim $ escaped + + myNixPath :: Text -> IO [String] + myNixPath path = concat <$> mapM getNivAssign ["home-manager", "nixpkgs", "unstable"] + where + tag name str = ["-I", [i|#{name :: Text}=#{str :: Text}|]] :: [String] + getNivAssign name = tag name <$> getNivPath path name + + main :: IO () + ${code} + ''; + get-niv-path = self.writeHaskellScript { name = "get-niv-path"; } '' + main = do + [sources, channel] <- fmap toText <$> getArgs + path <- getNivPath sources channel + say path + ''; +} diff --git a/pkgs/default.nix b/pkgs/default.nix deleted file mode 100644 index 3b1d03c6..00000000 --- a/pkgs/default.nix +++ /dev/null @@ -1,58 +0,0 @@ -let - my-lib = import ../lib; - inherit (my-lib) pkgs; -in rec { - obelisk = (import pkgs.sources.obelisk { }).command; - nix-direnv = pkgs.sources.nix-direnv + "/direnvrc"; - - # pkgs assumed to be present on a non nixos host - core-system-pkgs = { - inherit (pkgs) - gitFull gnumake mkpasswd file wget curl wireguard gnupg mutt bind liboping - psmisc unzip rename whois lsof parted python3 binutils ntfsprogs neovim; - }; - - extra-system-pkgs = { - inherit (pkgs.python3Packages) qrcode; - inherit (pkgs) - git-crypt htop tree pwgen borgbackup inotifyTools direnv socat nmap ncdu - tcpdump tmux tig exa fzf ag fd bat ripgrep ranger pass sshuttle vnstat - entr libargon2 mblaze niv; - }; - - my-home-pkgs = { - print215 = pkgs.writeShellScriptBin "print215" '' - scp "$@" ag-forward: - ssh ag-forward lpr -Zduplex -r "$@" - ''; - print215single = pkgs.writeShellScriptBin "print215single" '' - scp "$@" ag-forward: - ssh ag-forward lpr -r "$@" - ''; - }; - desktop-pkgs = { - inherit (pkgs) lm_sensors xwayland xdg_utils libnotify; - inherit (pkgs.gnomeExtensions) appindicator system-monitor; - inherit (pkgs.gnome3) - dconf dconf-editor gnome-tweaks gnome-shell-extensions adwaita-icon-theme - gnome-session; - }; - home-pkgs = { - inherit (pkgs.pythonPackages) yapf jsbeautifier; - inherit (pkgs.haskellPackages) brittany ormolu releaser; - inherit (pkgs) - go gdb mpc_cli ncmpcpp shfmt htmlTidy astyle nodejs tasksh magic-wormhole - nixfmt stack ghcid rnix-lsp tmate rustup kitty ghc cabal-install; - inherit obelisk; - }; - accounting-pkgs = { - inherit (pkgs.haskellPackages) hledger hledger-ui hledger-web; - inherit (pkgs) ledger jali; - }; - system-pkgs = core-system-pkgs // extra-system-pkgs // { - inherit (import ../lib/test.nix) - test-system-config test-home-config test-config; - inherit (my-lib) home-manager; - }; - foreign-home-pkgs = extra-system-pkgs; -} diff --git a/system/default.nix b/system/default.nix index e4f2237b..696b39ef 100644 --- a/system/default.nix +++ b/system/default.nix @@ -11,11 +11,7 @@ in { i18n = { defaultLocale = "en_US.UTF-8"; }; # For nixos-rebuild - nixpkgs.overlays = let overlayPath = ../overlays; - in map (n: import (overlayPath + ("/" + n))) (builtins.filter (n: - builtins.match ".*\\.nix" n != null - || builtins.pathExists (overlayPath + ("/" + n + "/default.nix"))) - (lib.attrNames (builtins.readDir overlayPath))); + nixpkgs.overlays = import ../overlays.nix { inherit lib; }; time.timeZone = "Europe/Berlin"; @@ -53,7 +49,7 @@ in { [ "https://cache.nixos.org/" "https://nixcache.reflex-frp.org" ]; binaryCachePublicKeys = [ "ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=" ]; - nixPath = [ "/etc/nix-path" "nixpkgs-overlays=/etc/nixos/overlays" ]; + nixPath = [ "/etc/nix-path" ]; extraOptions = '' fallback = true keep-outputs = true diff --git a/system/standalone/default.nix b/system/standalone/default.nix index 0d62c4c1..942e1dbe 100644 --- a/system/standalone/default.nix +++ b/system/standalone/default.nix @@ -26,10 +26,12 @@ environment = { # Put these into an extra file so the essential packages can also be included on non selfadminstrated systems from home-manager systemPackages = builtins.attrValues ({ - inherit (import ../../lib/update-system.nix - config.system.build.nixos-rebuild) + inherit (import ../../lib/update-system.nix { + inherit pkgs; + nixos-rebuild = config.system.build.nixos-rebuild; + }) update-system; - } // (import ../../pkgs).system-pkgs); + } // pkgs.system-pkgs); }; programs = {