Added steam and flatpak modules. Fixed steam with impermanence
This commit is contained in:
parent
37f843170a
commit
47412f3ecf
7 changed files with 171 additions and 83 deletions
17
flake.lock
generated
17
flake.lock
generated
|
|
@ -768,6 +768,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-flatpak": {
|
||||
"locked": {
|
||||
"lastModified": 1734128415,
|
||||
"narHash": "sha256-HLwdVNxpuTsLlM3tCkpbQU6yCehdgf3kOS1G2SDlkzY=",
|
||||
"owner": "gmodena",
|
||||
"repo": "nix-flatpak",
|
||||
"rev": "8bdc2540da516006d07b04019eb57ae0781a04b3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "gmodena",
|
||||
"ref": "latest",
|
||||
"repo": "nix-flatpak",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-formatter-pack": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
|
@ -3213,6 +3229,7 @@
|
|||
"impermanence": "impermanence",
|
||||
"neovim": "neovim",
|
||||
"nix-darwin": "nix-darwin",
|
||||
"nix-flatpak": "nix-flatpak",
|
||||
"nix-gaming": "nix-gaming",
|
||||
"nix-on-droid": "nix-on-droid",
|
||||
"nixos-facter-modules": "nixos-facter-modules",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
};
|
||||
hyprland.url = "github:hyprwm/Hyprland";
|
||||
stylix.url = "github:danth/stylix";
|
||||
#nix-flatpak.url = "github:GermanBread/declarative-flatpak/stable-v3";
|
||||
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest";
|
||||
apple-silicon-support.url = "github:tpwrules/nixos-apple-silicon";
|
||||
|
||||
#nur.url = "github:nix-community/NUR";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
inputs.disko.nixosModules.default
|
||||
|
||||
./modules/firefox
|
||||
./modules/flatpak
|
||||
./modules/steam
|
||||
./modules/services/autoupgrade
|
||||
./modules/sops
|
||||
./hosts/${hwconfig.hostname}
|
||||
|
|
@ -73,6 +75,13 @@
|
|||
# networking.proxy.default = "http://user:password@proxy:port/";
|
||||
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
|
||||
|
||||
#flatpak
|
||||
kk.services.flatpak.enable = true;
|
||||
services.flatpak.packages = [
|
||||
"com.super_productivity.SuperProductivity"
|
||||
"net.cozic.joplin_desktop"
|
||||
];
|
||||
|
||||
# Enable networking
|
||||
networking.networkmanager.enable = true;
|
||||
|
||||
|
|
@ -247,13 +256,6 @@
|
|||
|
||||
security.polkit.enable = true;
|
||||
|
||||
programs.steam = {
|
||||
enable = hwconfig.system == "x86_64-linux";
|
||||
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
|
||||
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
|
||||
localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers
|
||||
};
|
||||
|
||||
#programs.thunar = {
|
||||
# enable = true;
|
||||
# plugins = with pkgs.xfce; [
|
||||
|
|
@ -338,6 +340,8 @@
|
|||
# enableSSHSupport = true;
|
||||
# };
|
||||
|
||||
kk.steam.enable = hwconfig.system == "x86_64-linux";
|
||||
|
||||
# List services that you want to enable:
|
||||
|
||||
# Enable the OpenSSH daemon.
|
||||
|
|
|
|||
19
nixos/modules/flatpak/default.nix
Normal file
19
nixos/modules/flatpak/default.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
inputs,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.kk.services.flatpak;
|
||||
in {
|
||||
imports = [
|
||||
inputs.nix-flatpak.nixosModules.nix-flatpak
|
||||
];
|
||||
options.kk.services.flatpak = {
|
||||
enable = lib.mkEnableOption "enable flatpaks";
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.flatpak.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,57 +1,73 @@
|
|||
{ config, lib, inputs, ... }:
|
||||
let
|
||||
isBtrfs = config.fileSystems."/".fsType == "btrfs";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
inputs.impermanence.nixosModules.impermanence
|
||||
];
|
||||
fileSystems."/persist".neededForBoot = true;
|
||||
environment.persistence."/persist/system" = {
|
||||
config,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
isBtrfs = config.fileSystems."/".fsType == "btrfs";
|
||||
in {
|
||||
imports = [
|
||||
inputs.impermanence.nixosModules.impermanence
|
||||
];
|
||||
fileSystems."/persist".neededForBoot = true;
|
||||
environment.persistence."/persist/system" = {
|
||||
hideMounts = true;
|
||||
directories = [
|
||||
"/etc/nixos"
|
||||
"/var/log"
|
||||
"/var/lib/bluetooth"
|
||||
"/var/lib/nixos"
|
||||
"/var/lib/systemd/coredump"
|
||||
"/etc/NetworkManager/system-connections"
|
||||
{ directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; }
|
||||
"/etc/nixos"
|
||||
"/var/log"
|
||||
"/var/lib/bluetooth"
|
||||
"/var/lib/nixos"
|
||||
"/var/lib/flatpak"
|
||||
"/var/lib/systemd/coredump"
|
||||
"/etc/NetworkManager/system-connections"
|
||||
{
|
||||
directory = "/var/lib/colord";
|
||||
user = "colord";
|
||||
group = "colord";
|
||||
mode = "u=rwx,g=rx,o=";
|
||||
}
|
||||
];
|
||||
files = [
|
||||
"/etc/machine-id"
|
||||
{ file = "/var/keys/secret_file"; parentDirectory = { mode = "u=rwx,g=,o="; }; }
|
||||
];
|
||||
};
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /persist/home/ 0777 root root -" # /persist/home created, owned by root
|
||||
#"d /persist/home/${username} 0700 ${username} users -" # /persist/home/<user> created, owned by that user
|
||||
#"d /persist/nixos-config 0700 ${username} users -"
|
||||
"/etc/machine-id"
|
||||
{
|
||||
file = "/var/keys/secret_file";
|
||||
parentDirectory = {mode = "u=rwx,g=,o=";};
|
||||
}
|
||||
];
|
||||
};
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /persist/home/ 0777 root root -" # /persist/home created, owned by root
|
||||
#"d /persist/home/${username} 0700 ${username} users -" # /persist/home/<user> created, owned by that user
|
||||
#"d /persist/nixos-config 0700 ${username} users -"
|
||||
];
|
||||
|
||||
programs.fuse.userAllowOther = true;
|
||||
boot.initrd.postDeviceCommands = lib.mkAfter (if isBtrfs then ''
|
||||
mkdir /btrfs_tmp
|
||||
mount /dev/root_vg/root /btrfs_tmp
|
||||
if [[ -e /btrfs_tmp/root ]]; then
|
||||
mkdir -p /btrfs_tmp/old_roots
|
||||
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
|
||||
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
|
||||
fi
|
||||
programs.fuse.userAllowOther = true;
|
||||
boot.initrd.postDeviceCommands = lib.mkAfter (
|
||||
if isBtrfs
|
||||
then ''
|
||||
mkdir /btrfs_tmp
|
||||
mount /dev/root_vg/root /btrfs_tmp
|
||||
if [[ -e /btrfs_tmp/root ]]; then
|
||||
mkdir -p /btrfs_tmp/old_roots
|
||||
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
|
||||
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
|
||||
fi
|
||||
|
||||
delete_subvolume_recursively() {
|
||||
IFS=$'\n'
|
||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||
delete_subvolume_recursively "/btrfs_tmp/$i"
|
||||
done
|
||||
btrfs subvolume delete "$1"
|
||||
}
|
||||
delete_subvolume_recursively() {
|
||||
IFS=$'\n'
|
||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||
delete_subvolume_recursively "/btrfs_tmp/$i"
|
||||
done
|
||||
btrfs subvolume delete "$1"
|
||||
}
|
||||
|
||||
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
|
||||
delete_subvolume_recursively "$i"
|
||||
done
|
||||
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
|
||||
delete_subvolume_recursively "$i"
|
||||
done
|
||||
|
||||
btrfs subvolume create /btrfs_tmp/root
|
||||
umount /btrfs_tmp
|
||||
'' else '''');
|
||||
btrfs subvolume create /btrfs_tmp/root
|
||||
umount /btrfs_tmp
|
||||
''
|
||||
else ''''
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,37 @@
|
|||
{ username, inputs, ... }:
|
||||
{
|
||||
imports = [
|
||||
inputs.impermanence.nixosModules.home-manager.impermanence
|
||||
];
|
||||
home.persistence."/persist/home/${username}" = {
|
||||
username,
|
||||
inputs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
inputs.impermanence.nixosModules.home-manager.impermanence
|
||||
];
|
||||
home.persistence."/persist/home/${username}" = {
|
||||
directories = [
|
||||
"Downloads"
|
||||
"Music"
|
||||
"Pictures"
|
||||
"Documents"
|
||||
"Videos"
|
||||
"VMs"
|
||||
"Git"
|
||||
"nixos-config"
|
||||
"blender"
|
||||
".gnupg"
|
||||
".ssh"
|
||||
".nixops"
|
||||
".local/share/keyrings"
|
||||
".local/share/direnv"
|
||||
{
|
||||
directory = ".local/share/Steam";
|
||||
#method = "symlink";
|
||||
}
|
||||
".steam"
|
||||
".mozilla"
|
||||
".local/share/TelegramDesktop"
|
||||
".config/solaar"
|
||||
".config/kdeconnect"
|
||||
".config/blender"
|
||||
"Downloads"
|
||||
"Music"
|
||||
"Pictures"
|
||||
"Documents"
|
||||
"Videos"
|
||||
"VMs"
|
||||
"Git"
|
||||
"nixos-config"
|
||||
"blender"
|
||||
".gnupg"
|
||||
".ssh"
|
||||
".nixops"
|
||||
".local/share/keyrings"
|
||||
".local/share/direnv"
|
||||
#{
|
||||
# directory = ".local/share/Steam";
|
||||
# method = "symlink";
|
||||
#}
|
||||
#".steam"
|
||||
".mozilla"
|
||||
".local/share/TelegramDesktop"
|
||||
".config/solaar"
|
||||
".config/kdeconnect"
|
||||
".config/blender"
|
||||
];
|
||||
files = [
|
||||
".screenrc"
|
||||
|
|
|
|||
29
nixos/modules/steam/default.nix
Normal file
29
nixos/modules/steam/default.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
hwconfig,
|
||||
...
|
||||
}: let
|
||||
cfg = config.kk.steam;
|
||||
in {
|
||||
options.kk.steam = {
|
||||
enable = lib.mkEnableOption "Enable steam";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (
|
||||
if hwconfig.useImpermanence
|
||||
then {
|
||||
kk.services.flatpak.enable = lib.mkForce true;
|
||||
services.flatpak.packages = ["com.valvesoftware.Steam"];
|
||||
}
|
||||
else {
|
||||
programs.steam = {
|
||||
enable = !hwconfig.useImpermanence;
|
||||
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
|
||||
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
|
||||
localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue