Cosmic: Don't use unstablepkgs for vm by default. make it buildable with stable nixos.

This commit is contained in:
Wroclaw 2024-03-14 13:57:54 +01:00
parent b79c776d97
commit b4cd6cf85b
3 changed files with 24 additions and 5 deletions

View file

@ -1,15 +1,24 @@
{pkgs, lib, ... }: {config, lib, pkgs, ... }:
let let
nixos-cosmic = builtins.fetchGit { nixos-cosmic = builtins.fetchGit {
url = "https://github.com/lilyinstarlight/nixos-cosmic.git"; url = "https://github.com/lilyinstarlight/nixos-cosmic.git";
# rev = "b61e7a0da2fa1d5f05d41e3db6386b2ac5f5079b"; # rev = "b61e7a0da2fa1d5f05d41e3db6386b2ac5f5079b";
}; };
unstablePkgs = import (builtins.fetchTarball "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz");
cosmicPkgsMainDir = builtins.readDir "${nixos-cosmic}/pkgs"; cosmicPkgsMainDir = builtins.readDir "${nixos-cosmic}/pkgs";
cosmicPkgsDirs = builtins.filter (v: cosmicPkgsMainDir."${v}" == "directory") (builtins.attrNames cosmicPkgsMainDir); cosmicPkgsDirs = builtins.filter (v: cosmicPkgsMainDir."${v}" == "directory") (builtins.attrNames cosmicPkgsMainDir);
cosmicPkgsOverlay = final: prev: builtins.listToAttrs ( cosmicPkgsOverlay = final: prev: builtins.listToAttrs (
builtins.map (v: {name = v; value = final.callPackage "${nixos-cosmic}/pkgs/${v}/package.nix" {};}) cosmicPkgsDirs builtins.map (v: {name = v; value = final.callPackage "${nixos-cosmic}/pkgs/${v}/package.nix" {};}) cosmicPkgsDirs
); );
cosmicPkgs = unstablePkgs {
inherit (config.nixpkgs) config localSystem crossSystem;
overlays = [ cosmicPkgsOverlay ];
};
finalOverlay = finial: prev: lib.filterAttrs (n: v: builtins.elem n cosmicPkgsDirs) cosmicPkgs;
in in
{ {
imports = [ imports = [
@ -17,7 +26,7 @@ in
]; ];
config = { config = {
services.xserver.desktopManager.cosmic.enable = true; services.xserver.desktopManager.cosmic.enable = true;
nixpkgs.overlays = [ cosmicPkgsOverlay ]; nixpkgs.overlays = [ finalOverlay ];
nix.settings = { nix.settings = {
substituters = [ "https://cosmic.cachix.org/" ]; substituters = [ "https://cosmic.cachix.org/" ];
trusted-public-keys = [ "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" ]; trusted-public-keys = [ "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" ];

View file

@ -1,15 +1,25 @@
{pkgs, lib, ... }: {config, lib, pkgs, ... }:
let let
nixos-cosmic = builtins.fetchGit { nixos-cosmic = builtins.fetchGit {
url = "https://github.com/lilyinstarlight/nixos-cosmic.git"; url = "https://github.com/lilyinstarlight/nixos-cosmic.git";
# rev = "b61e7a0da2fa1d5f05d41e3db6386b2ac5f5079b"; # rev = "b61e7a0da2fa1d5f05d41e3db6386b2ac5f5079b";
}; };
unstablePkgs = import (builtins.fetchTarball "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz");
cosmicPkgsMainDir = builtins.readDir "${nixos-cosmic}/pkgs"; cosmicPkgsMainDir = builtins.readDir "${nixos-cosmic}/pkgs";
cosmicPkgsDirs = builtins.filter (v: cosmicPkgsMainDir."${v}" == "directory") (builtins.attrNames cosmicPkgsMainDir); cosmicPkgsDirs = builtins.filter (v: cosmicPkgsMainDir."${v}" == "directory") (builtins.attrNames cosmicPkgsMainDir);
cosmicPkgsOverlay = final: prev: builtins.listToAttrs ( cosmicPkgsOverlay = final: prev: builtins.listToAttrs (
builtins.map (v: {name = v; value = final.callPackage "${nixos-cosmic}/pkgs/${v}/package.nix" {};}) cosmicPkgsDirs builtins.map (v: {name = v; value = final.callPackage "${nixos-cosmic}/pkgs/${v}/package.nix" {};}) cosmicPkgsDirs
); );
cosmicPkgs = unstablePkgs {
inherit (config.nixpkgs) config localSystem crossSystem;
overlays = [ cosmicPkgsOverlay ];
};
finalOverlay = finial: prev: lib.filterAttrs (n: v: builtins.elem n cosmicPkgsDirs) cosmicPkgs;
in in
{ {
imports = [ imports = [
@ -18,7 +28,7 @@ in
config = { config = {
services.xserver.desktopManager.cosmic.enable = true; services.xserver.desktopManager.cosmic.enable = true;
services.xserver.displayManager.cosmic-greeter.enable = true; services.xserver.displayManager.cosmic-greeter.enable = true;
nixpkgs.overlays = [ cosmicPkgsOverlay ]; nixpkgs.overlays = [ finalOverlay ];
nix.settings = { nix.settings = {
substituters = [ "https://cosmic.cachix.org/" ]; substituters = [ "https://cosmic.cachix.org/" ];
trusted-public-keys = [ "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" ]; trusted-public-keys = [ "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" ];

View file

@ -1 +1 @@
nix-build '<nixos-unstable/nixos>' -A vm -I nixpkgs=channel:nixos-unstable -I nixos-config=./nix-os-configs/vm-cosmic.nix $@ && $(ls ./result/bin/run-*) -m 4096 && rm *.qcow2 nix-build '<nixpkgs/nixos>' -A vm -I nixpkgs=channel:nixos-23.11 -I nixos-config=./nix-os-configs/vm-cosmic.nix $@ && $(ls ./result/bin/run-*) -m 4096 && rm *.qcow2