cosmic module

This commit is contained in:
RingOfStorms (Joshua Bell) 2024-10-10 14:12:31 -05:00
parent 25e19e9256
commit bb8033d547
8 changed files with 168 additions and 70 deletions

70
flake.lock generated
View file

@ -24,6 +24,27 @@
"type": "github" "type": "github"
} }
}, },
"cosmic": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable",
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1728530651,
"narHash": "sha256-b3icYsSiWvjeunpgoRmvmCxh1ak+oXpWEqHuzNgC7wM=",
"owner": "lilyinstarlight",
"repo": "nixos-cosmic",
"rev": "9bdf58ccc52095d846186cb3549122205b36991a",
"type": "github"
},
"original": {
"owner": "lilyinstarlight",
"repo": "nixos-cosmic",
"type": "github"
}
},
"crane": { "crane": {
"locked": { "locked": {
"lastModified": 1725409566, "lastModified": 1725409566,
@ -99,8 +120,7 @@
"gpdPocket3_home-manager": { "gpdPocket3_home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixos-cosmic", "gpdPocket3_nixpkgs"
"nixpkgs-stable"
] ]
}, },
"locked": { "locked": {
@ -118,6 +138,22 @@
"type": "github" "type": "github"
} }
}, },
"gpdPocket3_nixpkgs": {
"locked": {
"lastModified": 1728500571,
"narHash": "sha256-dOymOQ3AfNI4Z337yEwHGohrVQb4yPODCW9MDUyAc4w=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d51c28603def282a24fa034bcb007e2bcb5b5dd0",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"h002_home-manager": { "h002_home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -214,27 +250,6 @@
"type": "github" "type": "github"
} }
}, },
"nixos-cosmic": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable",
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1728530651,
"narHash": "sha256-b3icYsSiWvjeunpgoRmvmCxh1ak+oXpWEqHuzNgC7wM=",
"owner": "lilyinstarlight",
"repo": "nixos-cosmic",
"rev": "9bdf58ccc52095d846186cb3549122205b36991a",
"type": "github"
},
"original": {
"owner": "lilyinstarlight",
"repo": "nixos-cosmic",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1728241625, "lastModified": 1728241625,
@ -1146,16 +1161,13 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"cosmic": "cosmic",
"gpdPocket3_home-manager": "gpdPocket3_home-manager", "gpdPocket3_home-manager": "gpdPocket3_home-manager",
"gpdPocket3_nixpkgs": [ "gpdPocket3_nixpkgs": "gpdPocket3_nixpkgs",
"nixos-cosmic",
"nixpkgs-stable"
],
"h002_home-manager": "h002_home-manager", "h002_home-manager": "h002_home-manager",
"h002_nixpkgs": "h002_nixpkgs", "h002_nixpkgs": "h002_nixpkgs",
"joe_home-manager": "joe_home-manager", "joe_home-manager": "joe_home-manager",
"joe_nixpkgs": "joe_nixpkgs", "joe_nixpkgs": "joe_nixpkgs",
"nixos-cosmic": "nixos-cosmic",
"nixpkgs_stable": "nixpkgs_stable", "nixpkgs_stable": "nixpkgs_stable",
"nypkgs": "nypkgs", "nypkgs": "nypkgs",
"ragenix": "ragenix", "ragenix": "ragenix",
@ -1165,7 +1177,7 @@
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixos-cosmic", "cosmic",
"nixpkgs" "nixpkgs"
] ]
}, },

View file

@ -20,15 +20,10 @@
inputs.nixpkgs.follows = "h002_nixpkgs"; inputs.nixpkgs.follows = "h002_nixpkgs";
}; };
# COSMIC gpdPocket3_nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixos-cosmic = {
url = "github:lilyinstarlight/nixos-cosmic";
# inputs.nixpkgs.follows = "nixos-cosmic/nixpkgs";
};
gpdPocket3_nixpkgs.follows = "nixos-cosmic/nixpkgs-stable";
gpdPocket3_home-manager = { gpdPocket3_home-manager = {
url = "github:nix-community/home-manager/release-24.05"; url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixos-cosmic/nixpkgs-stable"; inputs.nixpkgs.follows = "gpdPocket3_nixpkgs";
}; };
nixpkgs_stable.url = "github:nixos/nixpkgs/nixos-24.05"; nixpkgs_stable.url = "github:nixos/nixpkgs/nixos-24.05";
@ -47,6 +42,9 @@
url = "git+https://git.joshuabell.xyz/nvim"; url = "git+https://git.joshuabell.xyz/nvim";
}; };
cosmic = {
url = "github:lilyinstarlight/nixos-cosmic";
};
}; };
outputs = outputs =
@ -91,6 +89,9 @@
inherit user; inherit user;
nixpkgs = gpdPocket3_nixpkgs; nixpkgs = gpdPocket3_nixpkgs;
home-manager = gpdPocket3_home-manager; home-manager = gpdPocket3_home-manager;
# There is no way to support top level conditional imports in modules using that module's options...
# so for now I have this hack until I want to make this more broad
uses_cosmic = true;
}; };
} }
{ {
@ -127,12 +128,21 @@
acc acc
// { // {
"${nixConfig.name}" = "${nixConfig.name}" =
nixConfig.settings.nixpkgs.lib.nixosSystem { let
modules = [ lib = nixConfig.settings.nixpkgs.lib;
./hosts/_common/configuration.nix ylib = nypkgs.legacyPackages.${nixConfig.opts.system}.lib;
]; in
(lib.nixosSystem {
modules =
[
./hosts/_common/configuration.nix
]
++ ylib.umport {
path = lib.fileset.maybeMissing ./modules;
recursive = true;
};
specialArgs = inputs // { specialArgs = inputs // {
ylib = nypkgs.legacyPackages.${nixConfig.opts.system}.lib; inherit ylib;
settings = settings =
directories directories
// nixConfig.settings // nixConfig.settings
@ -142,7 +152,7 @@
}; };
}; };
}; };
} })
// nixConfig.opts; // nixConfig.opts;
} }
) { } myHosts; ) { } myHosts;

View file

@ -1,11 +1,11 @@
{ nixos-cosmic, pkgs, ... }: { cosmic, ... }:
{ {
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=" ];
}; };
imports = [ nixos-cosmic.nixosModules.default ]; imports = [ cosmic.nixosModules.default ];
services.desktopManager.cosmic.enable = true; services.desktopManager.cosmic.enable = true;
services.displayManager.cosmic-greeter.enable = true; services.displayManager.cosmic-greeter.enable = true;

View file

@ -4,7 +4,7 @@
pkgs, pkgs,
settings, settings,
... ...
}@args: }:
{ {
imports = [ imports = [
# Common components this machine uses # Common components this machine uses
@ -16,7 +16,7 @@
# (settings.hostsDir + "/_common/components/audio.nix") # (settings.hostsDir + "/_common/components/audio.nix")
(settings.hostsDir + "/_common/components/home_manager.nix") (settings.hostsDir + "/_common/components/home_manager.nix")
# (settings.hostsDir + "/_common/components/gnome_wayland.nix") # (settings.hostsDir + "/_common/components/gnome_wayland.nix")
(settings.hostsDir + "/_common/components/cosmic.nix") # (settings.hostsDir + "/_common/components/cosmic.nix")
(settings.hostsDir + "/_common/components/docker.nix") (settings.hostsDir + "/_common/components/docker.nix")
(settings.hostsDir + "/_common/components/nebula.nix") (settings.hostsDir + "/_common/components/nebula.nix")
# Users this machine has # Users this machine has
@ -27,30 +27,7 @@
# ./stupid-keyboard-2.nix # ./stupid-keyboard-2.nix
]; ];
nixpkgs.overlays = [ my_modules.de_cosmic.enable = true;
(final: prev: {
cosmic-comp = prev.cosmic-comp.overrideAttrs (prevAttrs: {
patches = (prevAttrs.patches or [ ]) ++ [
(final.writeText "cosmic-comp-disable-direct-scanout.patch" ''
diff --git a/src/backend/kms/surface/mod.rs b/src/backend/kms/surface/mod.rs
index d0cfb8d..32aaf4a 100644
--- a/src/backend/kms/surface/mod.rs
+++ b/src/backend/kms/surface/mod.rs
@@ -624,7 +624,8 @@ impl SurfaceThreadState {
cursor_size,
Some(gbm),
) {
- Ok(compositor) => {
+ Ok(mut compositor) => {
+ compositor.use_direct_scanout(false);
self.active.store(true, Ordering::SeqCst);
self.compositor = Some(compositor);
Ok(())
'')
];
});
})
];
# machine specific configuration # machine specific configuration
# ============================== # ==============================

34
modules/de_cosmic.nix Normal file
View file

@ -0,0 +1,34 @@
{
cosmic,
config,
lib,
settings,
...
}:
with lib;
let
# name = "de_cosmic";
# cfg = config.my_modules.${name};
in
{
options = {
my_modules.de_cosmic = {
enable = mkEnableOption (lib.mdDoc "Enable COSMIC desktop environment");
};
};
# Import the module from nix flake https://github.com/lilyinstarlight/nixos-cosmic
imports = optional settings.uses_cosmic cosmic.nixosModules.default;
config = mkIf config.my_modules.de_cosmic.enable {
# Use cosmic binary cache
nix.settings = {
substituters = [ "https://cosmic.cachix.org/" ];
trusted-public-keys = [ "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" ];
};
services.desktopManager.cosmic.enable = true;
services.displayManager.cosmic-greeter.enable = true;
};
}

View file

@ -0,0 +1,21 @@
{
config,
lib,
...
}:
with lib;
let
name = "de_gnome_wayland";
cfg = config.my_modules.${name};
in
{
options = {
my_modules.${name} = {
enable = mkEnableOption (lib.mdDoc "Enable GNOME with wayland desktop environment");
};
};
config = mkIf cfg.enable {
# TODO
};
}

22
modules/de_gnome_xorg.nix Normal file
View file

@ -0,0 +1,22 @@
{
config,
lib,
...
}:
with lib;
let
name = "de_gnome_xorg";
cfg = config.my_modules.${name};
in
{
options = {
my_modules.${name} = {
enable = mkEnableOption "Enable GNOME with wayland desktop environment";
};
};
config = mkIf cfg.enable {
# TODO
};
}

22
modules/validations.nix Normal file
View file

@ -0,0 +1,22 @@
{ lib, config, ... }:
{
# config.assertions = [
# {
# assertion =
# lib.length (
# lib.filter (x: x) [
# config.my_modules.de_cosmic.enable
# config.my_modules.de_gnome_xorg.enable
# config.my_modules.de_gnome_wayland.enable
# ]
# ) <= 1;
# message = ''
# Configuration Error: Multiple desktop environments are enabled.
# Please enable only one of the following:
# - my_modules.de_cosmic.enable
# - my_modules.de_gnome_xorg.enable
# - my_modules.de_gnome_wayland.enable
# '';
# }
# ];
}