1
0
Fork 0

Massive restructure

This commit is contained in:
Malte Brandy 2020-05-27 15:20:08 +02:00
parent e783f8c45b
commit a81cca3e20
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
44 changed files with 222 additions and 508 deletions

View file

@ -1,5 +1,5 @@
let
inherit (import <nixpkgs> { }) 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: {

View file

@ -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;
}

View file

@ -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

View file

@ -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; };

View file

@ -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";
};

View file

@ -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"

View file

@ -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 ];

View file

@ -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)" ];

17
home/home-options.nix Normal file
View file

@ -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;
};
};
};
}

View file

@ -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 ];
} ''

View file

@ -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 ];

View file

@ -1,5 +1,5 @@
let
inherit (import <nixpkgs> { }) 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)

View file

@ -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" ]; };
};
};
};
}

View file

@ -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));
};
}

View file

@ -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;
};
};
};
}

View file

@ -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;
};
};
};
}

View file

@ -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;
};
}

View file

@ -1,5 +1,5 @@
let
inherit (import <nixpkgs> { }) lib pkgs;
inherit (import (import ../nix/sources.nix).nixpkgs { }) lib pkgs;
modes = import ./modes.nix;
home-manager = import <home-manager/home-manager/home-manager.nix>;
buildHomeManager = attr:

View file

@ -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

View file

@ -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;
};
}

View file

@ -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;
};
};
}

Binary file not shown.

View file

@ -1,4 +0,0 @@
#!/bin/sh
. ~/.nix-profile/etc/profile.d/nix.sh
. ~/.nix-profile/etc/profile.d/hm-session-vars.sh
exec "$@"

View file

@ -1,2 +0,0 @@
#!/bin/sh
exec ~/bin/proot -b ~/.nix:/nix bin/run-in-nix $@

View file

@ -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
'')
];
};
}

View file

@ -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";
};
};
};
}

View file

@ -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";
};
};
};
}

View file

@ -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";
};
};
};
}

View file

@ -19,79 +19,4 @@ rec {
"white" = "#dddbff";
"brightWhite" = "#ffffff";
};
pkgs = import <nixpkgs> { };
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 <home-manager/home-manager> { };
}

View file

@ -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
'';
}

View file

@ -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 ];
} ''

11
overlays.nix Normal file
View file

@ -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

View file

@ -1,6 +0,0 @@
self: super:
if super.config.allowUnfree or false then
{ }
else {
unfree = import <nixpkgs> { config.allowUnfree = true; };
}

View file

@ -2,7 +2,7 @@ self: super:
let
preview = version: func:
if super.lib.versionOlder super.lib.version version then
func (import <unstable> { })
func (import self.sources.unstable { })
else
{ };
in preview "20.09pre-git" (unstable: {

6
overlays/20-unfree.nix Normal file
View file

@ -0,0 +1,6 @@
self: super:
if super.config.allowUnfree or false then
{ }
else {
unfree = import self.sources.nixpkgs { config.allowUnfree = true; };
}

View file

@ -0,0 +1 @@
self: super: { grafana-devel = self.callPackage ./package.nix { }; }

View file

@ -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;

52
overlays/pkgSets.nix Normal file
View file

@ -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;
}

View file

@ -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 $ ["<nixpkgs/nixos>", "-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"
'';

View file

@ -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
'';
}

View file

@ -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;
}

View file

@ -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

View file

@ -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 = {