1
0
Fork 0

Improve mode management

This commit is contained in:
Malte Brandy 2020-05-09 16:04:35 +02:00
parent d19cdcc8f5
commit e7fc7a1218
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
2 changed files with 28 additions and 26 deletions

View file

@ -1,24 +1,16 @@
let
inherit (import <nixpkgs> { }) lib;
home-manager = import <home-manager/home-manager/home-manager.nix>;
buildHomeManager = attr:
(home-manager {
confPath = ~/git/config/home.nix;
confAttr = attr;
}).activationPackage;
makeConfig = hostName: imports:
{ ... }: {
imports = imports ++ [ ./home ];
m-0.hostName = hostName;
};
wrapWithOthers = config: all:
{ lib, ... }: {
imports = [ config ];
home.file = lib.listToAttrs (builtins.map (name: {
inherit name;
value = {
source = (import <home-manager/home-manager/home-manager.nix> {
confPath = ~/git/config/home.nix;
confAttr = "apollo-${name}-without-symlinks";
}).activationPackage;
target = ".gc-roots-home/${name}";
};
}) (lib.attrNames all));
};
apollo = let
setStartpage = startpage:
{ ... }: {
@ -121,13 +113,9 @@ in {
home/headless-mpd.nix
home/mail.nix
];
} // lib.listToAttrs (lib.flatten (lib.mapAttrsToList (name: config: [
} // lib.listToAttrs (lib.mapAttrsToList (name: config:
{
name = "apollo-${name}";
value = wrapWithOthers config apollo;
}
{
name = "apollo-${name}-without-symlinks";
value = config;
}
]) apollo))
) apollo)

View file

@ -1,18 +1,32 @@
{ pkgs, ... }:
let inherit (import ../lib) unfreePkgs;
{ pkgs, lib, ... }:
let
inherit (import ../lib) unfreePkgs;
modes = builtins.filter (lib.hasPrefix "apollo-")
(pkgs.lib.attrNames (import ../home.nix));
in {
home.packages = builtins.attrValues {
maintenance = pkgs.writeShellScriptBin "maintenance" ''
git -C ~/git/config pull
update-home-mode
update-modes
sudo -A update-system
sudo -A nix optimise-store
'';
updateHome = pkgs.writeShellScriptBin "update-home-mode" ''
update-home -A apollo-`cat ~/tmp/mode`
activateMode = pkgs.writeShellScriptBin "activate-mode" ''
~/.modes/result-home-manager-$(cat ~/tmp/mode)/activate
'';
updateModes = pkgs.writeShellScriptBin "update-modes" ''
set -e
mkdir -p ~/.modes
cd ~/.modes
${lib.concatStringsSep "\n"
(map (mode: "test-home-config ~/git/config ${mode}") modes)}
activate-mode
'';
selectMode = pkgs.writeShellScriptBin "select-mode" ''
${pkgs.dialog}/bin/dialog --menu "Select Mode" 20 80 5 research "" orga "" tinkering "" leisure "" 2> ~/tmp/mode
${pkgs.dialog}/bin/dialog --menu "Select Mode" 20 80 5 ${
lib.concatStrings (map (mode: "${mode} '' ") modes)
} 2> ~/tmp/mode
activate-mode
'';
inherit (unfreePkgs) zoom-us skypeforlinux google-chrome;