added secrets
This commit is contained in:
		
							
								
								
									
										4
									
								
								home/config/dwm/autostart.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								home/config/dwm/autostart.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
picom --experimental-backends &
 | 
			
		||||
~/.dwm/bruhstatus.sh &
 | 
			
		||||
feh --bg-scale ~/Downloads/stallman.jpg
 | 
			
		||||
							
								
								
									
										47
									
								
								home/config/dwm/bruhstatus.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										47
									
								
								home/config/dwm/bruhstatus.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,47 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
prevtotload=0
 | 
			
		||||
previdleload=0
 | 
			
		||||
#tt=$(date +"%s")
 | 
			
		||||
#bgfile=$(ls ~/Wallpapers/** | shuf -n 1)
 | 
			
		||||
#for N in {99..1}; do
 | 
			
		||||
#    magick convert $bgfile -fill black -colorize $N% jpg:- | feh --bg-scale -
 | 
			
		||||
#done
 | 
			
		||||
#feh --bg-scale $bgfile
 | 
			
		||||
while true; do
 | 
			
		||||
    cputemp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))
 | 
			
		||||
    gputemp=$(nvidia-smi | head -n 10 | tail -n 1 |awk '{print $3}'| cut -c 1-2)
 | 
			
		||||
    totmem=$(cat /proc/meminfo | awk '/MemTotal:/ {print $2}')
 | 
			
		||||
    echo $totmem
 | 
			
		||||
    availmem=$(cat /proc/meminfo | awk '/MemAvailable:/ {print $2}')
 | 
			
		||||
    echo $availmem
 | 
			
		||||
    totload=$(cat /proc/stat | awk '/cpu/'|head -n 1|awk '{print $2+$3+$4+$5+$6+$7+$8}')
 | 
			
		||||
    echo $totload
 | 
			
		||||
    idleload=$(cat /proc/stat | awk '/cpu/'|head -n 1|awk '{print $5}')
 | 
			
		||||
    echo $idleload
 | 
			
		||||
    totloadchange=$(($totload-$prevtotload))
 | 
			
		||||
    idleloadchange=$(($idleload-$previdleload))
 | 
			
		||||
    xsetroot -name\
 | 
			
		||||
        "CPU [$(printf %0.2f $(echo "($totloadchange-$idleloadchange)*100/$totloadchange" | bc -l))%]\
 | 
			
		||||
  MEM [$(printf %0.2f $(echo \($totmem - $availmem\)/1024/1024|bc -l))/\
 | 
			
		||||
$(printf %0.2f $(echo $totmem/1024/1024 | bc -l))]\
 | 
			
		||||
  TEMP [$cputemp°C|$gputemp°C]\
 | 
			
		||||
  BAT$($(cat /sys/class/power_supply/BAT1/status | grep -q Discharging) && echo " " || echo "")\
 | 
			
		||||
[$(cat /sys/class/power_supply/BAT1/capacity)%]\
 | 
			
		||||
  VOL [$(pamixer --get-volume)]\
 | 
			
		||||
  [$(date +"%a, %b %d") | $(date +"%H:%M:%S")]"
 | 
			
		||||
    prevtotload=$totload
 | 
			
		||||
    previdleload=$idleload
 | 
			
		||||
   # if [ $(echo $tt+44 | bc -l) -lt $(date +"%s") ]
 | 
			
		||||
   # then
 | 
			
		||||
        #for N in {1..99}; do
 | 
			
		||||
        #    magick convert $bgfile -fill black -colorize $N% jpg:- | feh --bg-scale -
 | 
			
		||||
        #done
 | 
			
		||||
      #  bgfile=$(ls ~/Wallpapers/** | shuf -n 1)
 | 
			
		||||
        #for N in {99..1}; do
 | 
			
		||||
        #    magick convert $bgfile -fill black -colorize $N% jpg:- | feh --bg-scale -
 | 
			
		||||
        #done    
 | 
			
		||||
     #   feh --bg-scale $bgfile
 | 
			
		||||
      #  tt=$(date +"%s")
 | 
			
		||||
    #fi
 | 
			
		||||
    sleep 15
 | 
			
		||||
done
 | 
			
		||||
@@ -1,15 +0,0 @@
 | 
			
		||||
{config, ...}:
 | 
			
		||||
let
 | 
			
		||||
  home = config.home.homeDirectory;
 | 
			
		||||
in {
 | 
			
		||||
  home = {
 | 
			
		||||
    file.ncmpcpp = {
 | 
			
		||||
      source = ../config/ncmpcpp/config;
 | 
			
		||||
      target = "${home}/.config/ncmpcpp/config";
 | 
			
		||||
    };
 | 
			
		||||
    file.mpd = {
 | 
			
		||||
      source = ../config/mpd/mpd.conf;
 | 
			
		||||
      target = "${home}/.config/mpd/mpd.conf";
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
@@ -1,20 +1,41 @@
 | 
			
		||||
{ config, pkgs, ... }:
 | 
			
		||||
 | 
			
		||||
{ config, pkgs, lib, ... }:
 | 
			
		||||
let
 | 
			
		||||
  home = config.home.homeDirectory;
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  imports = [
 | 
			
		||||
    ./modules/programs.nix 
 | 
			
		||||
    ./modules/xsession.nix
 | 
			
		||||
    ./modules/files.nix
 | 
			
		||||
    ./modules/services.nix
 | 
			
		||||
    ./modules/gtk.nix
 | 
			
		||||
    ./stuff/programs.nix 
 | 
			
		||||
    ./stuff/xsession.nix
 | 
			
		||||
    ./stuff/secret.nix
 | 
			
		||||
    ./stuff/services.nix
 | 
			
		||||
    ./stuff/gtk.nix
 | 
			
		||||
  ];
 | 
			
		||||
  nixpkgs = {
 | 
			
		||||
    config = {
 | 
			
		||||
      allowUnfree = true;
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  age = {
 | 
			
		||||
    sshKeyPaths = [ "${home}/.ssh/id_ed25519" ];
 | 
			
		||||
    secrets = {
 | 
			
		||||
      fish_variables = {
 | 
			
		||||
        file = ./secrets/fish_variables.age;
 | 
			
		||||
        path = "${home}/.config/fish/fish_variables";
 | 
			
		||||
      };
 | 
			
		||||
      mpdasrc = {
 | 
			
		||||
        file = ./secrets/mpdasrc.age;
 | 
			
		||||
        path = "${home}/.config/mpdasrc";
 | 
			
		||||
      };
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
  home = {
 | 
			
		||||
    packages = with pkgs; [
 | 
			
		||||
      ffmpeg
 | 
			
		||||
      sox
 | 
			
		||||
      rage
 | 
			
		||||
      curl
 | 
			
		||||
      pamixer
 | 
			
		||||
      mpdas
 | 
			
		||||
      mpd
 | 
			
		||||
      dunst
 | 
			
		||||
@@ -31,8 +52,30 @@
 | 
			
		||||
      tor-browser-bundle-bin
 | 
			
		||||
      mpc_cli
 | 
			
		||||
      flameshot
 | 
			
		||||
      hexchat
 | 
			
		||||
      luajit
 | 
			
		||||
      mpv
 | 
			
		||||
      jmtpfs
 | 
			
		||||
      youtube-dl
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    file = {
 | 
			
		||||
      ncmpcpp = {
 | 
			
		||||
        source = ./config/ncmpcpp/config;
 | 
			
		||||
        target = "${home}/.config/ncmpcpp/config";
 | 
			
		||||
      };
 | 
			
		||||
      mpd = {
 | 
			
		||||
        source = ./config/mpd/mpd.conf;
 | 
			
		||||
        target = "${home}/.config/mpd/mpd.conf";
 | 
			
		||||
      };
 | 
			
		||||
      dwm-autostart = {
 | 
			
		||||
        source = ./config/dwm/autostart.sh;
 | 
			
		||||
        target = "${home}/.dwm/autostart.sh";
 | 
			
		||||
      };
 | 
			
		||||
      dwm-status = {
 | 
			
		||||
        source = ./config/dwm/bruhstatus.sh;
 | 
			
		||||
        target = "${home}/.dwm/bruhstatus.sh";
 | 
			
		||||
      };
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
{config, ...}:
 | 
			
		||||
{
 | 
			
		||||
  imports = [
 | 
			
		||||
    ./modules/programs/nvim.nix
 | 
			
		||||
    ./modules/gtk.nix
 | 
			
		||||
  ];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								home/secrets/fish_variables.age
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								home/secrets/fish_variables.age
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								home/secrets/mpdasrc.age
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								home/secrets/mpdasrc.age
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										93
									
								
								home/stuff/secret.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								home/stuff/secret.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,93 @@
 | 
			
		||||
/* Module by @ryantm in github:ryantm/agenix 
 | 
			
		||||
Modified by @natto1784 for 'personal' home-manager config */
 | 
			
		||||
 | 
			
		||||
{ config, lib, pkgs, ... }:
 | 
			
		||||
 | 
			
		||||
with lib;
 | 
			
		||||
 | 
			
		||||
let
 | 
			
		||||
  cfg = config.age;
 | 
			
		||||
  ageBin = "${pkgs.rage}/bin/rage";
 | 
			
		||||
  users = config.users.users;
 | 
			
		||||
  home_ = config.home.homeDirectory;
 | 
			
		||||
  username_ = config.home.username;
 | 
			
		||||
  identities = builtins.concatStringsSep " " (map (path: "-i ${path}") cfg.sshKeyPaths);
 | 
			
		||||
  installSecret = secretType: ''
 | 
			
		||||
    echo "decrypting ${secretType.file} to ${secretType.path}..." 
 | 
			
		||||
    TMP_FILE="${secretType.path}.tmp"
 | 
			
		||||
    mkdir -p $(dirname ${secretType.path})
 | 
			
		||||
    (umask 0400; ${ageBin} --decrypt ${identities} -o "$TMP_FILE" "${secretType.file}")
 | 
			
		||||
    chmod ${secretType.mode} "$TMP_FILE"
 | 
			
		||||
    chown ${secretType.owner} "$TMP_FILE"
 | 
			
		||||
    mv -f "$TMP_FILE" '${secretType.path}'
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  secretType = types.submodule ({ config, ... }: {
 | 
			
		||||
    options = {
 | 
			
		||||
      name = mkOption {
 | 
			
		||||
        type = types.str;
 | 
			
		||||
        default = config._module.args.name;
 | 
			
		||||
        description = ''
 | 
			
		||||
          Name of the file used in /run/secrets
 | 
			
		||||
        '';
 | 
			
		||||
      };
 | 
			
		||||
      file = mkOption {
 | 
			
		||||
        type = types.path;
 | 
			
		||||
        description = ''
 | 
			
		||||
          Age file the secret is loaded from.
 | 
			
		||||
        '';
 | 
			
		||||
      };
 | 
			
		||||
      path = mkOption {
 | 
			
		||||
          type = types.str;
 | 
			
		||||
          default = "${home_}/.secrets/${config.name}";
 | 
			
		||||
          description = ''
 | 
			
		||||
            Path where the decrypted secret is installed.
 | 
			
		||||
          '';
 | 
			
		||||
        };
 | 
			
		||||
      mode = mkOption {
 | 
			
		||||
        type = types.str;
 | 
			
		||||
        default = "0400";
 | 
			
		||||
        description = ''
 | 
			
		||||
          Permissions mode of the in octal.
 | 
			
		||||
        '';
 | 
			
		||||
      };
 | 
			
		||||
      owner = mkOption {
 | 
			
		||||
        type = types.str;
 | 
			
		||||
        default = "${username_}";
 | 
			
		||||
        description = ''
 | 
			
		||||
          User of the file.
 | 
			
		||||
        '';
 | 
			
		||||
      };
 | 
			
		||||
    };
 | 
			
		||||
  });
 | 
			
		||||
in {
 | 
			
		||||
  
 | 
			
		||||
  options.age = {
 | 
			
		||||
    secrets = mkOption {
 | 
			
		||||
      type = types.attrsOf secretType;
 | 
			
		||||
      default = {};
 | 
			
		||||
      description = ''
 | 
			
		||||
        Attrset of secrets.
 | 
			
		||||
      '';
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    sshKeyPaths = mkOption {
 | 
			
		||||
      type = types.listOf types.path;
 | 
			
		||||
      default = [  ];
 | 
			
		||||
      description = ''
 | 
			
		||||
        Path to SSH keys to be used as identities in age decryption.
 | 
			
		||||
      '';
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
  config = mkIf (cfg.secrets != {}) {
 | 
			
		||||
    assertions = [{
 | 
			
		||||
      assertion = cfg.sshKeyPaths != [];
 | 
			
		||||
      message = "age.sshKeyPaths must be set.";
 | 
			
		||||
    }];
 | 
			
		||||
    home.activation = {
 | 
			
		||||
      decryptSecrets = lib.hm.dag.entryBefore [ "writeBoundary" ] (concatStrings (map installSecret (builtins.attrValues cfg.secrets)));
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user