From 11b9855244c9a3d45d0a027ab6f36fe088de7723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Montero?= Date: Tue, 29 Nov 2022 13:55:12 -0600 Subject: [PATCH] =?UTF-8?q?separa=20configuraci=C3=B3n=20en=20plataformas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + base/platforms/posixlycorrect.nix | 3 ++ flake.nix | 51 +++++++++++++++++++++++++------ home/default.nix | 5 +-- home/gui/i3.nix | 9 +++--- home/local.nix | 19 ++++++++++++ home/platforms/posixlycorrect.nix | 6 ++++ home/platforms/thinkpad.nix | 6 ++++ 8 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 .gitignore create mode 100644 base/platforms/posixlycorrect.nix create mode 100644 home/local.nix create mode 100644 home/platforms/posixlycorrect.nix create mode 100644 home/platforms/thinkpad.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/base/platforms/posixlycorrect.nix b/base/platforms/posixlycorrect.nix new file mode 100644 index 0000000..077404a --- /dev/null +++ b/base/platforms/posixlycorrect.nix @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/flake.nix b/flake.nix index 140671c..b3180b0 100644 --- a/flake.nix +++ b/flake.nix @@ -19,19 +19,50 @@ pkgs = import nixpkgs { inherit system; }; + + inherit (pkgs) lib; + + base = platform: { + name = platform; + value = nixpkgs.lib.nixosSystem { + inherit system; + + modules = [ ( import ./base ) ]; + }; + }; + + home = platform: { + name = "fabian@${platform}"; + value = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + + modules = [ + (import ./home { + inherit self nixpkgs unstable hm-isolation; + }) + + ./home/platforms/${platform}.nix + + { + config.local = { inherit platform; }; + } + ]; + }; + }; + + platforms = domain: + map + (lib.removeSuffix ".nix") + (lib.attrNames (builtins.readDir ./${domain}/platforms)); + + configs = domain: builder: + lib.listToAttrs + (map builder (platforms domain)); in { - nixosConfigurations.posixlycorrect = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ ( import ./base ) ]; - }; - - homeConfigurations."fabian@posixlycorrect" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - modules = [ (import ./home {inherit self nixpkgs unstable hm-isolation; }) ]; - }; + nixosConfigurations = configs "base" base; + homeConfigurations = configs "home" home; packages."${system}" = packages pkgs; diff --git a/home/default.nix b/home/default.nix index 9deedcd..361ebb6 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,14 +1,15 @@ -{ nixpkgs, unstable, self, hm-isolation }: +{ self, nixpkgs, unstable, hm-isolation }: { config, pkgs, lib, ... } : with lib; { imports = [ (hm-isolation.homeManagerModule) + ./allowUnfreeWhitelist.nix ./gui ./isolation.nix + ./local.nix ./path.nix ./systemd - ./allowUnfreeWhitelist.nix ]; nixpkgs.overlays = [ self.overlay ]; diff --git a/home/gui/i3.nix b/home/gui/i3.nix index dbe4c8e..78566d2 100644 --- a/home/gui/i3.nix +++ b/home/gui/i3.nix @@ -87,14 +87,13 @@ with lib; workspaceOutputAssign = [ { - output = "DisplayPort-0"; + output = config.local.display."0"; workspace = "1"; } - { - output = "DisplayPort-1"; + ] ++ optional (config.local.display."1" != null) { + output = config.local.display."1"; workspace = "10"; - } - ]; + }; bars = [ ]; }; diff --git a/home/local.nix b/home/local.nix new file mode 100644 index 0000000..6b832f7 --- /dev/null +++ b/home/local.nix @@ -0,0 +1,19 @@ +{ config, lib, ... } : +with lib; +{ + options.local = with types; { + platform = mkOption { + type = str; + }; + + display = { + "0" = mkOption { + type = str; + }; + + "1" = mkOption { + type = nullOr str; + }; + }; + }; +} \ No newline at end of file diff --git a/home/platforms/posixlycorrect.nix b/home/platforms/posixlycorrect.nix new file mode 100644 index 0000000..9c5e601 --- /dev/null +++ b/home/platforms/posixlycorrect.nix @@ -0,0 +1,6 @@ +{ + config.local.display = { + "0" = "DisplayPort-0"; + "1" = "DisplayPort-1"; + }; +} \ No newline at end of file diff --git a/home/platforms/thinkpad.nix b/home/platforms/thinkpad.nix new file mode 100644 index 0000000..198a2f9 --- /dev/null +++ b/home/platforms/thinkpad.nix @@ -0,0 +1,6 @@ +{ + config.local.display = { + "0" = "eDP-1"; + "1" = null; + }; +} \ No newline at end of file