From 44a4ac95a94c1238dc825f493902c29481cbd370 Mon Sep 17 00:00:00 2001 From: Tyler Beckman Date: Sat, 21 Dec 2024 22:29:34 -0700 Subject: [PATCH] Nix-on-droid fixes --- flake.nix | 5 +- home-manager/default.nix | 76 ++++++++++++++++----------- home-manager/meta.nix | 9 +++- hosts/laptop/config/networking.nix | 4 +- nix-on-droid/ty-pixel/default.nix | 28 ++++++---- nix-on-droid/ty-pixel/environment.nix | 20 +++++++ utils/default.nix | 13 ++++- 7 files changed, 108 insertions(+), 47 deletions(-) create mode 100644 nix-on-droid/ty-pixel/environment.nix diff --git a/flake.nix b/flake.nix index 1d2afab..9e12392 100755 --- a/flake.nix +++ b/flake.nix @@ -102,10 +102,7 @@ }; # Setup nix-on-droid configurations - nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration { - pkgs = import nixpkgs { system = "aarch64-linux"; }; - modules = [ ./nix-on-droid/ty-pixel ]; - }; + nixOnDroidConfigurations.default = utils.createDroidSystem { entrypoint = ./nix-on-droid/ty-pixel; }; # Enable direct flake support for colmena colmenaHive = colmena.lib.makeHive self.outputs.colmena; diff --git a/home-manager/default.nix b/home-manager/default.nix index 52e48e8..e23cfe8 100755 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -1,37 +1,51 @@ -{ inputs, system, secrets, lib, config, ... }: +{ inputs, system, secrets, config, lib, ... }: { imports = [ ./meta.nix ]; config = { - # Allow user installation of packages - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.sharedModules = [ - # Import plasma manager and all of my custom modules for use - inputs.plasma-manager.homeManagerModules.plasma-manager - inputs.flatpaks.homeManagerModules.declarative-flatpak - ./modules + home-manager = let + entrypoint = { + imports = [ + # Import meta options for configuring the configuration + ./meta.nix + # Import all of my config + ./config + ]; + + home.stateVersion = "24.05"; + + # Inherit my home manager config options + meta.home-manager = config.meta.home-manager; + }; + in lib.mkMerge [ + ## General home-manager.* options + { + # Allow user installation of packages + useGlobalPkgs = true; + useUserPackages = true; + sharedModules = [ + # Import plasma manager and all of my custom modules for use + inputs.plasma-manager.homeManagerModules.plasma-manager + inputs.flatpaks.homeManagerModules.declarative-flatpak + ./modules + ]; + # Inherit all of my nixos config custom arguments + extraSpecialArgs = { + inherit inputs system secrets; + }; + + # Hopefully avoid file conflicts + backupFileExtension = "bak"; + } + + # The nixos home-manager module and the nix-on-droid compatibility have different options, + # so this handles both in the same file + + (if (config.meta.home-manager.interface == "nixos") then { + users.ty = entrypoint; + } else { + config = entrypoint; + }) ]; - # Inherit all of my nixos config custom arguments - home-manager.extraSpecialArgs = { - inherit inputs system secrets; - }; - - # Hopefully avoid file conflicts - home-manager.backupFileExtension = "backup"; - - home-manager.users.ty = { - imports = [ - # Import meta options for configuring the configuration - ./meta.nix - # Import all of my config - ./config - ]; - - home.stateVersion = "24.05"; - - # Inherit my home manager config options - meta.home-manager = config.meta.home-manager; - }; }; -} \ No newline at end of file +} diff --git a/home-manager/meta.nix b/home-manager/meta.nix index 740163d..365864c 100644 --- a/home-manager/meta.nix +++ b/home-manager/meta.nix @@ -30,6 +30,13 @@ firefox.enable = lib.mkEnableOption "firefox configuration"; rescrobbled.enable = lib.mkEnableOption "rescrobbled configuration"; vscode.enable = lib.mkEnableOption "vscode configuration"; + + interface = lib.mkOption { + type = lib.types.enum [ "nixos" "nix-on-droid" ]; + default = "nixos"; + defaultText = lib.literalExpression ''"nixos"''; + description = "The interface to use for configuring home-manger as a module"; + }; }; # Handle preset logic @@ -57,4 +64,4 @@ vscode.enable = false; }) ]; -} \ No newline at end of file +} diff --git a/hosts/laptop/config/networking.nix b/hosts/laptop/config/networking.nix index 3b3a724..2ff70da 100644 --- a/hosts/laptop/config/networking.nix +++ b/hosts/laptop/config/networking.nix @@ -2,6 +2,8 @@ { networking.hostName = "ty-nixos"; + # networking.hosts = { "23.95.137.176" = [ "s.optifine.net" ]; }; + # Enable firewall networking.firewall.enable = true; @@ -17,4 +19,4 @@ # Network printing via CUPS services.printing.enable = true; -} \ No newline at end of file +} diff --git a/nix-on-droid/ty-pixel/default.nix b/nix-on-droid/ty-pixel/default.nix index e35461e..91cb7ba 100644 --- a/nix-on-droid/ty-pixel/default.nix +++ b/nix-on-droid/ty-pixel/default.nix @@ -1,15 +1,25 @@ -{ ... }: { - system.stateVersion = "24.05"; +{ inputs, system, secrets, pkgs, ... }: { + imports = [ + ./environment.nix - home-manager.config = { - imports = [ ../../home-manager ]; + # Import full home-manager config + ../../home-manager + ]; - meta.home-manager.preset = "cli"; + meta.home-manager = { preset = "cli"; interface = "nix-on-droid"; }; + + nix = { + extraOptions = '' + experimental-features = nix-command flakes + ''; + nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; }; - environment.etcBackupExtension = ".bak"; + user.shell = "${pkgs.zsh}/bin/zsh"; + time.timeZone = "America/Denver"; + terminal = { + font = "${pkgs.nerd-fonts.fira-code}/share/fonts/truetype/NerdFonts/FiraCode/FiraCodeNerdFont-Regular.ttf"; + }; - nix.extraOptions = '' - experimental-features = nix-command flakes - ''; + system.stateVersion = "24.05"; } diff --git a/nix-on-droid/ty-pixel/environment.nix b/nix-on-droid/ty-pixel/environment.nix new file mode 100644 index 0000000..1b18593 --- /dev/null +++ b/nix-on-droid/ty-pixel/environment.nix @@ -0,0 +1,20 @@ +{ pkgs, ... }: +{ + environment = { + etcBackupExtension = ".bak"; + + packages = with pkgs; [ + # Basic necessities + wget + curl + neovim + # Nix tools + nvd + # VCS + git + jujutsu + ]; + + motd = ""; + }; +} diff --git a/utils/default.nix b/utils/default.nix index 417f6fc..4b3371a 100644 --- a/utils/default.nix +++ b/utils/default.nix @@ -77,4 +77,15 @@ {} hostConfigs ); -} \ No newline at end of file + + createDroidSystem = { + system ? "aarch64-linux", + entrypoint + }: inputs.nix-on-droid.lib.nixOnDroidConfiguration { + pkgs = import inputs.nixpkgs { inherit system; }; + modules = [ entrypoint ]; + extraSpecialArgs = { + inherit inputs system secrets; + }; + }; +}