diff --git a/nix/steam_deck/configuration/flake.nix b/nix/steam_deck/configuration/flake.nix index 6d87f5d..e68e05f 100644 --- a/nix/steam_deck/configuration/flake.nix +++ b/nix/steam_deck/configuration/flake.nix @@ -33,6 +33,7 @@ extraSpecialArgs = { inherit nixgl; }; modules = [ + ./hosts/deck ./home.nix { nixpkgs.overlays = [ nixgl.overlay ]; } ]; diff --git a/nix/steam_deck/configuration/home.nix b/nix/steam_deck/configuration/home.nix index 7232bff..dfe20e9 100644 --- a/nix/steam_deck/configuration/home.nix +++ b/nix/steam_deck/configuration/home.nix @@ -6,6 +6,12 @@ ... }: { + imports = [ + ./util/unfree_polyfill + ./roles/shipwright + ./roles/graphics + ]; + home.username = "deck"; home.homeDirectory = "/home/deck"; home.stateVersion = "24.11"; diff --git a/nix/steam_deck/configuration/hosts/deck/default.nix b/nix/steam_deck/configuration/hosts/deck/default.nix new file mode 100644 index 0000000..f6de3f2 --- /dev/null +++ b/nix/steam_deck/configuration/hosts/deck/default.nix @@ -0,0 +1,15 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + config = { + me.graphical = true; + me.shipwright.enable = true; + }; +} diff --git a/nix/steam_deck/configuration/roles/graphics/default.nix b/nix/steam_deck/configuration/roles/graphics/default.nix new file mode 100644 index 0000000..c6f48d5 --- /dev/null +++ b/nix/steam_deck/configuration/roles/graphics/default.nix @@ -0,0 +1,43 @@ +{ + config, + lib, + pkgs, + nixgl, + ... +}: + +{ + imports = [ ]; + + options.me.graphics_card_type = lib.mkOption { + type = lib.types.nullOr ( + lib.types.enum [ + "amd" + "intel" + "nvidia" + ] + ); + default = null; + example = "amd"; + description = "What graphics card type is in the computer."; + }; + + options.me.graphical = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install graphical programs."; + }; + + config = ( + lib.mkMerge [ + (lib.mkIf config.me.graphical { + nixGL.packages = nixgl.packages; + # home.packages = with pkgs; [ + # mesa-demos # for glxgears + # vulkan-tools # for vkcube + # ]; + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/shipwright/default.nix b/nix/steam_deck/configuration/roles/shipwright/default.nix new file mode 100644 index 0000000..def9f7e --- /dev/null +++ b/nix/steam_deck/configuration/roles/shipwright/default.nix @@ -0,0 +1,34 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + shipwright.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install shipwright."; + }; + }; + + config = lib.mkIf config.me.shipwright.enable ( + lib.mkMerge [ + { + allowedUnfree = [ "shipwright" ]; + } + (lib.mkIf config.me.graphical { + home.packages = with pkgs; [ + (config.lib.nixGL.wrap shipwright) + ]; + + # TODO perhaps install ~/.local/share/soh/shipofharkinian.json + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/util/unfree_polyfill/default.nix b/nix/steam_deck/configuration/util/unfree_polyfill/default.nix new file mode 100644 index 0000000..d744cf4 --- /dev/null +++ b/nix/steam_deck/configuration/util/unfree_polyfill/default.nix @@ -0,0 +1,15 @@ +{ config, lib, ... }: + +let + inherit (builtins) elem; + inherit (lib) getName mkOption; + inherit (lib.types) listOf str; +in +{ + # Pending https://github.com/NixOS/nixpkgs/issues/55674 + options.allowedUnfree = mkOption { + type = listOf str; + default = [ ]; + }; + config.nixpkgs.config.allowUnfreePredicate = p: elem (getName p) config.allowedUnfree; +}