From d19cdcc8f52932a08e7cd886663e793a6179070f Mon Sep 17 00:00:00 2001 From: Malte Brandy Date: Sat, 9 May 2020 14:45:58 +0200 Subject: [PATCH] Build symlinks on apollo to always have all modes in a gc-root --- home.nix | 200 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 114 insertions(+), 86 deletions(-) diff --git a/home.nix b/home.nix index 7f7d7e38..35b6964d 100644 --- a/home.nix +++ b/home.nix @@ -1,98 +1,117 @@ let + inherit (import { }) lib; makeConfig = hostName: imports: { ... }: { imports = imports ++ [ ./home ]; m-0.hostName = hostName; }; - setStartpage = startpage: - { ... }: { - programs.firefox.profiles."fz2sm95u.default".settings = { - "browser.startup.homepage" = startpage; - }; + wrapWithOthers = config: all: + { lib, ... }: { + imports = [ config ]; + home.file = lib.listToAttrs (builtins.map (name: { + inherit name; + value = { + source = (import { + confPath = ~/git/config/home.nix; + confAttr = "apollo-${name}-without-symlinks"; + }).activationPackage; + target = ".gc-roots-home/${name}"; + }; + }) (lib.attrNames all)); }; - makeBlock = list: - { pkgs, lib, ... }: { - systemd.user = { - services.blockserver = { - Unit = { Description = "Serve a blocklist"; }; - Service = { - ExecStart = "${pkgs.python3}/bin/python -m http.server 8842 -d ${ - pkgs.writeTextDir "blocklist" (lib.concatStringsSep "\r\n" list) - }"; - Restart = "always"; - }; - Install = { WantedBy = [ "default.target" ]; }; + apollo = let + setStartpage = startpage: + { ... }: { + programs.firefox.profiles."fz2sm95u.default".settings = { + "browser.startup.homepage" = startpage; }; }; - }; - tinkerPages = [ - "reddit.com" - "github.com" - "*.ccc.de" - "haskell.org" - "*.haskell.org" - "*.nixos.org" - "nixos.org" - "matrix.org" - "riot.im" - ]; - leisurePages = [ - "zeit.de" - "heise.de" - "spiegel.de" - "youtube.de" - "youtube.com" - "xkcd.com" - "smbc-comics.com" - "tagesschau.de" - "welt.de" - "ndr.de" - "ard.de" - "zdf.de" - "twitter.com" - "chaos.social" - ]; - apolloConfig = imports: - makeConfig "apollo" (imports ++ [ - home/battery.nix - home/mpd.nix - home/mpclient.nix - home/on-my-machine.nix - home/desktop - home/firefox.nix - home/git-sign.nix - home/laptop.nix - ]); + makeBlock = list: + { pkgs, lib, ... }: { + systemd.user = { + services.blockserver = { + Unit = { Description = "Serve a blocklist"; }; + Service = { + ExecStart = "${pkgs.python3}/bin/python -m http.server 8842 -d ${ + pkgs.writeTextDir "blocklist" + (lib.concatStringsSep "\r\n" list) + }"; + Restart = "always"; + }; + Install = { WantedBy = [ "default.target" ]; }; + }; + }; + }; + tinkerPages = [ + "reddit.com" + "github.com" + "*.ccc.de" + "haskell.org" + "*.haskell.org" + "*.nixos.org" + "nixos.org" + "matrix.org" + "riot.im" + ]; + leisurePages = [ + "zeit.de" + "heise.de" + "spiegel.de" + "youtube.de" + "youtube.com" + "xkcd.com" + "smbc-comics.com" + "tagesschau.de" + "welt.de" + "ndr.de" + "ard.de" + "zdf.de" + "twitter.com" + "chaos.social" + ]; + apolloConfig = imports: + makeConfig "apollo" (imports ++ [ + home/battery.nix + home/mpd.nix + home/mpclient.nix + home/on-my-machine.nix + home/desktop + home/firefox.nix + home/git-sign.nix + home/laptop.nix + ]); + in { + orga = apolloConfig [ + home/accounting.nix + home/mail.nix + home/pythia.nix + home/update_tasks.nix + (setStartpage "https://cloud.maralorn.de/apps/calendar") + (makeBlock (tinkerPages ++ leisurePages)) + ]; + research = apolloConfig [ + home/latex.nix + (makeBlock (tinkerPages ++ leisurePages)) + (setStartpage "http://localhost:8042") + ]; + + tinkering = apolloConfig [ + home/mail.nix + home/update-script.nix + home/tinkering.nix + home/chat.nix + (makeBlock leisurePages) + (setStartpage "https://stats.maralorn.de/d/health-status") + ]; + leisure = apolloConfig [ + home/games.nix + home/chat.nix + (makeBlock [ ]) + (setStartpage "https://stats.maralorn.de/d/health-status") + ]; + }; + in { - apollo-orga = apolloConfig [ - home/accounting.nix - home/mail.nix - home/pythia.nix - home/update_tasks.nix - (setStartpage "https://cloud.maralorn.de/apps/calendar") - (makeBlock (tinkerPages ++ leisurePages)) - ]; - apollo-research = apolloConfig [ - home/latex.nix - (makeBlock (tinkerPages ++ leisurePages)) - (setStartpage "http://localhost:8042") - ]; - - apollo-tinkering = apolloConfig [ - home/mail.nix - home/update-script.nix - home/tinkering.nix - home/chat.nix - (makeBlock leisurePages) - (setStartpage "https://stats.maralorn.de/d/health-status") - ]; - apollo-leisure = apolloConfig [ - home/games.nix - home/chat.nix - (makeBlock [ ]) - (setStartpage "https://stats.maralorn.de/d/health-status") - ]; - hera = makeConfig "hera" [ ./home home/on-my-machine.nix @@ -102,4 +121,13 @@ in { home/headless-mpd.nix home/mail.nix ]; -} +} // lib.listToAttrs (lib.flatten (lib.mapAttrsToList (name: config: [ + { + name = "apollo-${name}"; + value = wrapWithOthers config apollo; + } + { + name = "apollo-${name}-without-symlinks"; + value = config; + } +]) apollo))