diff --git a/hosts/vm-cosmic.nix b/hosts/vm-cosmic.nix new file mode 100644 index 0000000..c842604 --- /dev/null +++ b/hosts/vm-cosmic.nix @@ -0,0 +1,17 @@ +{ inputs, ... }: + +{ + imports = [ + ./vm-base.nix + ../nix-os/desktopManagers/cosmic.nix + ../nix-os/displayManagers/cosmic-greeter.nix + ]; + + config = { + nixpkgs.overlays = [(import ../pkgs/overlays/cosmic-packages.nix { inherit inputs; })]; + nix.settings = { + substituters = [ "https://cosmic.cachix.org/" ]; + trusted-public-keys = [ "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" ]; + }; + }; +} diff --git a/inputs.nix b/inputs.nix index 6c3a94d..334379b 100644 --- a/inputs.nix +++ b/inputs.nix @@ -15,5 +15,10 @@ let self = { url = "https://github.com/NixOS/nixpkgs/archive/${lock.nixpkgs.revision}.tar.gz"; sha256 = "${lock.nixpkgs.sha256}"; }; + cosmic-modules = builtins.fetchTarball { + name = "cosmic-modules"; + url = "https://github.com/lilyinstarlight/nixos-cosmic/archive/${lock.cosmic-modules.revision}.tar.gz"; + sha256 = "${lock.cosmic-modules.sha256}"; + }; }; in self diff --git a/lock.nix b/lock.nix index fc5e288..28a61ca 100644 --- a/lock.nix +++ b/lock.nix @@ -7,4 +7,8 @@ revision = "883180e6550c1723395a3a342f830bfc5c371f6b"; sha256 = "01axrf25mahbxmp6vgfgx09dflbyaavr5liynkp6rpm4lkacr27f"; }; + cosmic-modules = { + revision = "d8b2b9aee034c10ca67848653171f576f87434a8"; + sha256 = "03i8smxgx2fdb9kkys81dihb5yja3nk9wjs1rx5h7f3b5kii1fd7"; + }; } diff --git a/nix-os/desktopManagers/cosmic.nix b/nix-os/desktopManagers/cosmic.nix new file mode 100644 index 0000000..96a1bf3 --- /dev/null +++ b/nix-os/desktopManagers/cosmic.nix @@ -0,0 +1,10 @@ +{ inputs, lib, pkgs, ... }: + +{ + imports = [ + "${inputs.cosmic-modules}/nixos/cosmic/module.nix" + ]; + config = { + services.desktopManager.cosmic.enable = true; + }; +} diff --git a/nix-os/displayManagers/cosmic-greeter.nix b/nix-os/displayManagers/cosmic-greeter.nix new file mode 100644 index 0000000..e39ab93 --- /dev/null +++ b/nix-os/displayManagers/cosmic-greeter.nix @@ -0,0 +1,10 @@ +{ inputs, lib, pkgs, ... }: + +{ + imports = [ + "${inputs.cosmic-modules}/nixos/cosmic-greeter/module.nix" + ]; + config = { + services.displayManager.cosmic-greeter.enable = true; + }; +} diff --git a/pkgs/overlays/cosmic-packages.nix b/pkgs/overlays/cosmic-packages.nix new file mode 100644 index 0000000..1722c18 --- /dev/null +++ b/pkgs/overlays/cosmic-packages.nix @@ -0,0 +1,46 @@ +{ inputs ? import ../../inputs.nix {}}: + +self: super: + +let + nixos-cosmic = inputs.cosmic-modules; + cosmicPkgsMainDir = builtins.readDir "${nixos-cosmic}/pkgs"; + cosmicPkgsDirs = builtins.filter (v: cosmicPkgsMainDir."${v}" == "directory") (builtins.attrNames cosmicPkgsMainDir); + + # FIXME: use unstable nixpkgs when rust 1.80 will be available in unstable + stagingNixpkgsSrc = builtins.fetchTarball { + name = "nixpkgs"; + url = "https://github.com/NixOS/nixpkgs/archive/b79cec4237cd0f655562890bf927466c68b48d68.tar.gz"; + sha256 = "1mswisq9iwffg2d6rfxvr27mvi4w853d9rn222s2g76445d0iqh8"; + }; + + # Take rustPackages from staging nixpkgs + stagingNixpkgs = import stagingNixpkgsSrc { + localSystem = self.stdenv.buildPlatform; + config = self.config; + } // (if self.stdenv.buildPlatform == self.stdenv.hostPlatform then {} else { + crossSystem = self.stdenv.hostPlatform; + }); + futureRustPackages = stagingNixpkgs.rustPackages; + + # Create nixpkgs with future rust + nixpkgsWithFutureRust = self.extend (futureSelf: futureSuper: { + rustPackages = futureRustPackages; + }); + + # Create cosmicPkgs that contains cosmic packages built from nixpkgs with future rust + cosmicOverlay = cosmicSelf: cosmicSuper: builtins.listToAttrs ( + builtins.map (v: {name = v; value = nixpkgsWithFutureRust.callPackage "${nixos-cosmic}/pkgs/${v}/package.nix" {};}) cosmicPkgsDirs + ); + cosmicNixpkgs = import inputs.nixpkgs { + localSystem = self.stdenv.buildPlatform; + config = self.config; + overlays = [ cosmicOverlay ]; + } // (if self.stdenv.buildPlatform == self.stdenv.hostPlatform then {} else { + crossSystem = self.stdenv.hostPlatform; + }); +in + +builtins.listToAttrs ( + builtins.map (v: {name = v; value = cosmicNixpkgs.${v};}) cosmicPkgsDirs +)