More flake fixes
This commit is contained in:
parent
6d98d85642
commit
597b50ebef
13 changed files with 133 additions and 27 deletions
|
@ -22,7 +22,10 @@ in
|
|||
nixpkgs.config.allowUnfree = true;
|
||||
nix = {
|
||||
package = lib.mkDefault pkgs.nixFlakes;
|
||||
settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
settings = {
|
||||
experimental-features = [ "nix-command" "flakes" ];
|
||||
warn-dirty = false;
|
||||
};
|
||||
};
|
||||
|
||||
programs =
|
||||
|
@ -453,6 +456,7 @@ in
|
|||
ncdu
|
||||
jdupes
|
||||
duperemove
|
||||
compsize
|
||||
|
||||
# local monitoring
|
||||
htop
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
./dev.nix
|
||||
./extra.nix
|
||||
./gaming
|
||||
./rebuild
|
||||
./ssh.nix
|
||||
./style.nix
|
||||
./usernix
|
||||
|
|
38
hm/rebuild/default.nix
Normal file
38
hm/rebuild/default.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{ pkgs, config, ... }:
|
||||
let
|
||||
ulf = pkgs.writers.writePython3 "update-local-flakes" {
|
||||
} (builtins.readFile ./update-local-flakes.py);
|
||||
in
|
||||
{
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "rb";
|
||||
runtimeInputs = [ pkgs.brightnessctl ];
|
||||
text = ''
|
||||
verb="switch"
|
||||
if [ "$#" -ge 1 ]
|
||||
then
|
||||
verb="$1"
|
||||
shift
|
||||
fi
|
||||
nixos_flake="/etc/nixos/flake.nix"
|
||||
if [ -f "$nixos_flake" ]
|
||||
then
|
||||
sudo ${ulf} "$nixos_flake"
|
||||
if [ "$verb" = "switch" ] || [ "$verb" = "test" ]
|
||||
then
|
||||
sudo nixos-rebuild "$verb" --specialisation ${config.frogeye.polarity} "$@"
|
||||
else
|
||||
sudo nixos-rebuild "$verb" "$@"
|
||||
fi
|
||||
fi
|
||||
hm_flake="${config.xdg.configHome}/home-manager/flake.nix"
|
||||
if [ -f "$hm_flake" ]
|
||||
then
|
||||
${ulf} "$hm_flake"
|
||||
home-manager "$verb" "$@"
|
||||
fi
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
53
hm/rebuild/update-local-flakes.py
Executable file
53
hm/rebuild/update-local-flakes.py
Executable file
|
@ -0,0 +1,53 @@
|
|||
import argparse
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
GET_INPUTS_CMD = [
|
||||
"nix-instantiate",
|
||||
"--eval",
|
||||
"--json", # This parser is stupid, better provide it with pre-eaten stuff
|
||||
"--expr",
|
||||
"builtins.fromJSON (builtins.toJSON (import ./flake.nix).inputs)",
|
||||
]
|
||||
|
||||
|
||||
def process_flake(flake: str) -> None:
|
||||
# get full path
|
||||
if not os.path.isfile(flake):
|
||||
raise FileNotFoundError(f"Flake not found: {flake}")
|
||||
dir = os.path.dirname(flake)
|
||||
# import dependencies
|
||||
p = subprocess.run(GET_INPUTS_CMD, cwd=dir, stdout=subprocess.PIPE)
|
||||
deps = json.loads(p.stdout)
|
||||
p.check_returncode()
|
||||
# for each dependency
|
||||
for dep_name, dep in deps.items():
|
||||
dep_url = dep["url"]
|
||||
# if not local path, continue
|
||||
if not (
|
||||
dep_url.startswith("path:") or dep_url.startswith("git+file:")
|
||||
):
|
||||
continue
|
||||
if dep.get("flake", True):
|
||||
# get flake file corresponding
|
||||
dep_path = dep_url.split(":")[1]
|
||||
if not dep_path.startswith("/"):
|
||||
dep_path = os.path.join(dir, dep_path)
|
||||
dep_path = os.path.normpath(dep_path)
|
||||
dep_flake = os.path.join(dep_path, "flake.nix")
|
||||
# call this function with the flake file
|
||||
process_flake(dep_flake)
|
||||
# update lockfile
|
||||
cmd = ["nix", "flake", "lock", "--update-input", dep_name]
|
||||
subprocess.run(cmd, cwd=dir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Recursively update lockfiles "
|
||||
"of flakes located on the system"
|
||||
)
|
||||
parser.add_argument("flake", help="Starting flake", default="flake.nix")
|
||||
args = parser.parse_args()
|
||||
process_flake(args.flake)
|
19
hm/style.nix
19
hm/style.nix
|
@ -1,9 +1,6 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
let
|
||||
# Currently last commit in https://github.com/danth/stylix/pull/194
|
||||
polarityFile = "${config.xdg.stateHome}/theme_polarity";
|
||||
polarityFromFile = if builtins.pathExists polarityFile then lib.strings.fileContents polarityFile else "light";
|
||||
polarity = if config.frogeye.polarity == "dynamic" then polarityFromFile else config.frogeye.polarity;
|
||||
phases = [
|
||||
{ command = "jour"; polarity = "light"; }
|
||||
{ command = "crepuscule"; polarity = "dark"; }
|
||||
|
@ -14,7 +11,7 @@ in
|
|||
{
|
||||
stylix = {
|
||||
|
||||
base16Scheme = "${pkgs.base16-schemes}/share/themes/solarized-${polarity}.yaml";
|
||||
base16Scheme = "${pkgs.base16-schemes}/share/themes/solarized-${config.frogeye.polarity}.yaml";
|
||||
image = builtins.fetchurl {
|
||||
url = "https://get.wallhere.com/photo/sunlight-abstract-minimalism-green-simple-circle-light-leaf-wave-material-line-wing-computer-wallpaper-font-close-up-macro-photography-124350.png";
|
||||
sha256 = "sha256:1zfq3f3v34i45mi72pkfqphm8kbhczsg260xjfl6dbydy91d7y93";
|
||||
|
@ -36,10 +33,6 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# Setting a custom base16 theme via nixvim:
|
||||
# - Is required so nixvim works
|
||||
# - For the rest only works on dark polarity, use the colorscheme otherwise... shrug
|
||||
# programs.nixvim.colorschemes.base16.colorscheme = "solarized-${polarity}";
|
||||
|
||||
# Fix https://nix-community.github.io/home-manager/index.html#_why_do_i_get_an_error_message_about_literal_ca_desrt_dconf_literal_or_literal_dconf_service_literal
|
||||
# home.packages = [ pkgs.dconf ];
|
||||
|
@ -53,14 +46,12 @@ in
|
|||
text = (lib.optionalString cfg.enable ''
|
||||
brightnessctl set ${builtins.getAttr phase.command cfg}
|
||||
'') + ''
|
||||
echo ${phase.polarity} > ${polarityFile}
|
||||
if command -v home-manager
|
||||
switch="/nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration"
|
||||
if [ -x "$switch" ]
|
||||
then
|
||||
home-manager switch
|
||||
else
|
||||
# In two steps to get the visual changes slightly earlier
|
||||
sudo /nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration test
|
||||
sudo /nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration boot
|
||||
sudo "$switch" test
|
||||
sudo "$switch" boot
|
||||
fi
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -27,6 +27,10 @@ in
|
|||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
# Setting a custom base16 theme via nixvim is required so feline works, and
|
||||
# because stylix makes a config that otherwise only works with dark
|
||||
# polarity.
|
||||
colorschemes.base16.colorscheme = "solarized-${config.frogeye.polarity}";
|
||||
options = {
|
||||
# From https://www.hillelwayne.com/post/intermediate-vim/
|
||||
title = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue