refactor: use $FLAKE instead of /home/mainUser...

This commit is contained in:
matt1432 2024-03-26 13:55:55 -04:00
parent 0fd7817932
commit 3f288f3e8f
8 changed files with 25 additions and 19 deletions
common

View file

@ -1,6 +1,7 @@
{
config,
home-manager,
lib,
nh,
nix-melt,
nur,
@ -64,7 +65,7 @@
extraArgs = "--keep-since 30d";
};
};
environment.variables.FLAKE = "/home/matt/.nix";
environment.variables.FLAKE = lib.mkDefault "/home/matt/.nix";
services = {
fwupd.enable = true;

View file

@ -1,6 +1,6 @@
# Check git status of nix configs
fetchNix() {(
cd ~/.nix || exit 1
cd "$FLAKE" || exit 1
git fetch --all --quiet
GIT=$(git -c color.status=always status |
grep -v -e "On branch" \

View file

@ -1,10 +1,4 @@
{
config,
pkgs,
...
}: let
inherit (config.vars) mainUser;
in {
{pkgs, ...}: {
programs = {
git = {
enable = true;
@ -75,9 +69,10 @@ in {
runtimeInputs = [git];
text = ''
DIR=''${1:-"/home/${mainUser}/.nix"}
DIR=''${1:-"$FLAKE"}
cd "$DIR" || exit 1
cd "$DIR"
git add flake.lock
git commit -m 'chore: update flake.lock'
git push

View file

@ -5,6 +5,7 @@
}: {
options.vars = let
inherit (lib) mkOption types;
flakeDir = config.environment.variables.FLAKE;
cfg = config.vars;
in {
mainUser = mkOption {
@ -49,7 +50,7 @@
configDir = mkOption {
type = types.str;
default = "/home/${cfg.mainUser}/.nix/devices/${cfg.hostName}/config";
default = "${flakeDir}/devices/${cfg.hostName}/config";
description = ''
The path to where most of the devices' configs are in the .nix folder
'';
@ -61,7 +62,7 @@
The name of the main monitor used for Hyprland
and Regreet which also uses Hyprland
'';
# This is to allow a bash script to know wether this value exists
# This is to allow a bash script to know whether this value exists
default = "null";
};