Merge branch 'main' into cosmic

This commit is contained in:
Wroclaw 2024-08-08 04:01:19 +02:00
commit b3550dc00a
21 changed files with 363 additions and 96 deletions

View file

@ -47,5 +47,5 @@ let
type != "unknown" && builtins.baseNameOf path != ".git" && !matchesGitIgnore path
) ./.;
in
if !(evaluatingInStore) then import selfInStore
else import ./outputs.nix
if !(evaluatingInStore) then { ... }@args: import selfInStore ({ selfPath = selfInStore; } // args )
else { ... }@args: import ./outputs.nix ({ selfPath = selfInStore; } // args)

View file

@ -1,52 +0,0 @@
{ inputs, pkgs, ... }:
{
imports = [
../nix-os/core.nix
../nix-os/core-desktop.nix
../nix-os/nvidia.nix
../nix-os/docker.nix
../nix-os/razer.nix
../nix-os/desktopManagers/gnome.nix
../nix-os/displayManagers/gdm.nix
#../nix-os/desktop/kde-plasma.nix
../nix-os/shell.nix
../nix-os/virtualization.nix
../nix-os/polkit/disable-shutdown.nix
../nix-os/locale.nix
../nix-os/adb.nix
../nix-os/account.nix
../nix-os/xdg-default-apps.nix
../nix-os/services/nix-binary-cache.nix
../nix-os/udev.nix
"${inputs.nixos-vscode-server}"
];
config = {
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "wroclaw-main";
services.xrdp.enable = true;
users.groups."tsusers".members = [ "wroclaw" ];
services.printing.drivers = with pkgs; [
hplip
];
# nixos-vscode-server module needs this
programs.nix-ld.enable = true;
services.vscode-server = {
enable = true;
extraRuntimeDependencies = with pkgs; [
docker
];
};
services.printing.startWhenNeeded = false;
system.stateVersion = "23.05";
};
}

64
hosts/main/default.nix Normal file
View file

@ -0,0 +1,64 @@
{ inputs, pkgs, ... }:
{
imports = [
../../nix-os/core.nix
../../nix-os/core-desktop.nix
../../nix-os/nvidia.nix
../../nix-os/docker.nix
../../nix-os/razer.nix
../../nix-os/desktopManagers/gnome.nix
../../nix-os/displayManagers/gdm.nix
../../nix-os/shell.nix
../../nix-os/virtualization.nix
../../nix-os/polkit/disable-shutdown.nix
../../nix-os/locale.nix
../../nix-os/adb.nix
../../nix-os/account.nix
../../nix-os/xdg-default-apps.nix
../../nix-os/services/nix-binary-cache.nix
../../nix-os/udev.nix
../../nix-os/gnupg.nix
"${inputs.nixos-vscode-server}"
];
config = {
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "wroclaw-main";
services.xrdp.enable = true;
users.groups."tsusers".members = [ "wroclaw" ];
services.printing.drivers = with pkgs; [
hplip
];
# nixos-vscode-server module needs this
programs.nix-ld.enable = true;
services.vscode-server = {
enable = true;
extraRuntimeDependencies = with pkgs; [
docker
];
};
services.pipewire.wireplumber.configPackages = [(
pkgs.stdenvNoCC.mkDerivation {
name = "wireplumber-config";
src = ./wireplumber;
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/share/wireplumber/wireplumber.conf.d
cp -r $src/* $out/share/wireplumber/wireplumber.conf.d
'';
}
)];
services.printing.startWhenNeeded = false;
system.stateVersion = "23.05";
};
}

View file

@ -0,0 +1,10 @@
monitor.alsa.rules = [{
matches = [{
node.name = "alsa_output.pci-0000_00_1f.3.iec958-stereo"
}]
actions = {
update-props = {
node.description = "Digital Output"
}
}
}]

View file

@ -0,0 +1,10 @@
monitor.alsa.rules = [{
matches = [{
node.name = "alsa_output.pci-0000_01_00.1.hdmi-stereo"
}]
actions = {
update-props = {
node.description = "Monitor speakers"
}
}
}]

View file

@ -0,0 +1,11 @@
monitor.alsa.rules = [{
matches = [{
device.name = "alsa_card.usb-Razer_Razer_USB_Audio_Controller_000000000000000000000000-00"
}]
actions = {
update-props = {
device.description = "Headphones"
device.profile = "Pro Audio"
}
}
}]

View file

@ -0,0 +1,10 @@
monitor.alsa.rules = [{
matches = [{
node.name = "alsa_input.usb-Razer_Razer_USB_Audio_Controller_000000000000000000000000-00.pro-input-0"
}]
actions = {
update-props = {
node.description = "Headphones"
}
}
}]

View file

@ -0,0 +1,22 @@
monitor.alsa.rules = [
{
matches = [{
node.name = "alsa_output.usb-Razer_Razer_USB_Audio_Controller_000000000000000000000000-00.pro-output-0"
}]
actions = {
update-props = {
node.description = "Headphones (Chat)"
}
}
}
{
matches = [{
node.name = "alsa_output.usb-Razer_Razer_USB_Audio_Controller_000000000000000000000000-00.pro-output-1"
}]
actions = {
update-props = {
node.description = "Headphones (Game)"
}
}
}
]

View file

@ -8,6 +8,7 @@
../nix-os/adb.nix
../nix-os/locale.nix
../nix-os/shell.nix
../nix-os/gnupg.nix
../nix-os/desktopManagers/gnome.nix
../nix-os/displayManagers/gdm.nix

View file

@ -4,7 +4,7 @@
sha256 = "1rq8mrlmbzpcbv9ys0x88alw30ks70jlmvnfr2j8v830yy5wvw7h";
};
nixpkgs = {
revision = "10c832d0548e9e3a6df7eb51e68c2783212a303e";
sha256 = "1p206hgfxbz0rmkzaslfrknbdss4n4dnb09pi5466h8ksmm8216q";
revision = "05405724efa137a0b899cce5ab4dde463b4fd30b";
sha256 = "06490pn22x9xl4chfx12iwdgx7nlbn14v8x05rnv2y1nancljisl";
};
}

View file

@ -21,7 +21,7 @@
proprietaryCodecs = true;
commandLineArgs = [ "--ozone-platform=wayland" ];
})
discord-canary
vesktop
unstablePkgs.vscode
gimp
inkscape

View file

@ -5,23 +5,7 @@
{ inputs, lib, pkgs, ... }:
let
/*
* pkg: package - nixpkgs package
* exe: string - executable (under bin) in pkgs
* wrapperArgs: string[] - arguments to pass to the wrapper
*/
mkWrappedExecutable = {pkg, exe ? pkg.meta.mainProgram, wrapperArgs}: let inherit (pkgs) lib makeWrapper; in lib.hiPrio (
pkgs.stdenv.mkDerivation {
inherit wrapperArgs;
name = "${pkg.name}-wrap-${exe}";
nativeBuildInputs = [ makeWrapper ];
phases = ["installPhase"];
installPhase = ''
mkdir -p $out/bin
makeWrapper ${pkg}/bin/${exe} $out/bin/${exe} $wrapperArgs
'';
}
);
inherit (pkgs) mkWrappedExecutable;
# bool -> nixpkgs[]
wrappedNixExecutables = inEnvironment: assert builtins.isBool inEnvironment; [
@ -79,6 +63,21 @@ in
rerere.enabled = true;
};
# Use nix-index for command-not-found handler
programs.command-not-found.enable = false;
programs.nix-index = {
package = pkgs.nix-index.override {
nix-index-unwrapped = pkgs.nix-index-unwrapped.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [] ++ [
../pkgs/by-name/ni/nix-index/cnfOutput.patch
];
});
};
enable = true;
enableBashIntegration = true;
};
# Enable fail2ban because of the OpenSSH server
services.fail2ban = {
enable = true;

15
nix-os/gnupg.nix Normal file
View file

@ -0,0 +1,15 @@
{ pkgs, ... }:
{
config = {
# Use pcscd for smartcard support
services.pcscd.enable = true;
environment.systemPackages = [(
pkgs.gnupg.overrideAttrs (superAttrs: {
configureFlags = superAttrs.configureFlags or []
++ [ "--disable-ccid-driver" ];
})
)];
};
}

View file

@ -13,10 +13,12 @@
open = false;
nvidiaSettings = true;
package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
version = "555.42.02";
sha256_64bit = "sha256-k7cI3ZDlKp4mT46jMkLaIrc2YUx1lh1wj/J4SVSHWyk=";
settingsSha256 = "sha256-rtDxQjClJ+gyrCLvdZlT56YyHQ4sbaL+d5tL4L4VfkA=";
persistencedSha256 = "";
version = "555.58.02";
sha256_64bit = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
sha256_aarch64 = "sha256-wb20isMrRg8PeQBU96lWJzBMkjfySAUaqt4EgZnhyF8=";
openSha256 = "sha256-8hyRiGB+m2hL3c9MDA/Pon+Xl6E788MZ50WrrAGUVuY=";
settingsSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8=";
persistencedSha256 = "sha256-a1D7ZZmcKFWfPjjH1REqPM5j/YLWKnbkP9qfRyIyxAw=";
};
};
nixpkgs.config.nvidia.acceptLicense = true;

View file

@ -1,11 +1,15 @@
{ inputs ? import ./inputs.nix {} }:
{
inputs ? import ./inputs.nix {},
selfPath ? ./.
}:
let
lib = (import "${inputs.nixpkgs}/lib").extend (import ./lib/overlays/version-info-fixup.nix { inherit inputs; });
self = {
inherit lib inputs;
inherit inputs lib self;
__toString = _: selfPath;
modifiedNixpkgs = import ./pkgs/top-level/impure.nix;
modifiedNixpkgsPure = import ./pkgs/top-level/default.nix;
overlays = {
@ -18,30 +22,30 @@ self = {
filePaths = lib.pipe ./hosts [
builtins.readDir
( lib.filterAttrs (name: type:
# filter out non-nix files
type == "regular"
# filter out files that don't end in .nix
&& lib.hasSuffix ".nix" name
( # regular .nix files
(type == "regular" && lib.hasSuffix ".nix" name)
|| # directories that contain a default.nix file
(type == "directory" && builtins.pathExists "${./hosts}/${name}/default.nix")
)
# filter out files that start with .
&& !lib.hasPrefix "." name
))
(lib.mapAttrsToList (name: _: name))
];
nixosSystem = import "${inputs.nixpkgs}/nixos/lib/eval-config.nix";
in
# mapped list of nix file paths to attrSet with initialized NixOS configurations,
# whose names are derived from file names
lib.pipe filePaths [
(builtins.map (name: {
name = builtins.substring 0 (builtins.stringLength name - 4) name;
(builtins.mapAttrs (name: type: {
name = if type == "directory" then name else builtins.substring 0 (builtins.stringLength name - 4) name;
value = nixosSystem {
inherit lib;
modules = [
./hosts/${name}
{
config.nixpkgs.overlays = [
( import ./pkgs/overlays/selfExpr.nix { nixpkgsPath = "${builtins.toString ./.}/pkgs/top-level/impure.nix"; } )
( import "${inputs.nixpkgs}/pkgs/top-level/by-name-overlay.nix" "${builtins.toString ./.}/pkgs/by-name" )
( import ./pkgs/overlays/selfExpr.nix { nixpkgsPath = "${self}/pkgs/top-level/impure.nix"; } )
( import ./pkgs/top-level/by-name-overlay.nix "${self}/pkgs/by-name" )
self.overlays.versionInfoFixup
];
}
@ -49,6 +53,7 @@ self = {
specialArgs = { inherit self inputs; };
};
}))
builtins.attrValues
builtins.listToAttrs
];
};

View file

@ -0,0 +1,29 @@
{
lib,
stdenv,
}:
{
src,
script,
...
} @ args:
lib.hiPrio (stdenv.mkDerivation (
{
src = src;
name = "${src.name}-script-override";
phases = [ "installPhase" "scriptOverridePhase" ];
installPhase = ''
runHook preInstall
cp -r $src $out
chmod u+w -R $out
runHook postInstall
'';
scriptOverridePhase = script;
} // lib.removeAttrs args [
"pkg"
"commands"
]
))

View file

@ -0,0 +1,22 @@
{
lib,
makeWrapper,
stdenv
}:
/*
pkg: package - nixpkgs package
exe: string - executable (under bin) in pkg
wrapperArgs: string[] - arguments to pass to the wrapper
*/
{ pkg, exe ? pkg.meta.mainProgram, wrapperArgs }:
lib.hiPrio (stdenv.mkDerivation {
inherit wrapperArgs;
name = "${pkg.name}-wrap-${exe}";
nativeBuildInputs = [ makeWrapper ];
phases = ["installPhase"];
installPhase = ''
mkdir -p $out/bin
makeWrapper ${pkg}/bin/${exe} $out/bin/${exe} $wrapperArgs
'';
})

View file

@ -0,0 +1,66 @@
diff --git a/command-not-found.sh b/command-not-found.sh
index 5f30bad..3854297 100755
--- a/command-not-found.sh
+++ b/command-not-found.sh
@@ -73,51 +73,30 @@ EOF
else
if [ -e "$HOME/.nix-profile/manifest.json" ]; then
>&2 cat <<EOF
-The program '$cmd' is currently not installed. You can install it
-by typing:
- nix profile install $toplevel#$attrs
-
-Or run it once with:
- nix shell $toplevel#$attrs -c $cmd ...
+The program '$cmd' is not in your PATH. You can make it available in an
+ephemeral shell by typing:
+ nix shell $toplevel#$attrs
EOF
else
>&2 cat <<EOF
-The program '$cmd' is currently not installed. You can install it
-by typing:
- nix-env -iA $toplevel.$attrs
-
-Or run it once with:
- nix-shell -p $attrs --run '$cmd ...'
+The program '$cmd' is not in your PATH. You can make it available in an
+ephemeral shell by typing:
+ nix-shell -p $attrs
EOF
fi
fi
;;
*)
>&2 cat <<EOF
-The program '$cmd' is currently not installed. It is provided by
-several packages. You can install it by typing one of the following:
-EOF
-
- # ensure we get each element of attrs
- # in a cross platform way
- while read attr; do
- if [ -e "$HOME/.nix-profile/manifest.json" ]; then
- >&2 echo " nix profile install $toplevel#$attr"
- else
- >&2 echo " nix-env -iA $toplevel.$attr"
- fi
- done <<< "$attrs"
-
- >&2 cat <<EOF
-
-Or run it once with:
+The program '$cmd' is not in your PATH. You can make it available in an
+ephemeral shell by typing:
EOF
while read attr; do
if [ -e "$HOME/.nix-profile/manifest.json" ]; then
- >&2 echo " nix shell $toplevel#$attr -c $cmd ..."
+ >&2 echo " nix shell $toplevel#$attr"
else
- >&2 echo " nix-shell -p $attr --run '$cmd ...'"
+ >&2 echo " nix-shell -p $attr"
fi
done <<< "$attrs"
;;

View file

@ -25,11 +25,13 @@ self: super: {
in ''
{ ... } @ args:
import ${nixpkgsPath} {
${self.lib.optionalString useConfig configText}
} // builtins.removeAttrs args (builtins.fromJSON '''
${removedAttrNamesText}
''')
import ${nixpkgsPath} (
{
${self.lib.optionalString useConfig configText}
} // builtins.removeAttrs args (builtins.fromJSON '''
${removedAttrNamesText}
''')
)
'';
mkNixpkgsChannel = args: self.writeTextFile {

View file

@ -0,0 +1,50 @@
# Modified copy of github:NixOS/nixpkgs pkgs/top-level/by-name-overlay.nix
# as of commit c0d0be00d4ecc4b51d2d6948e37466194c1e6c51
# This file turns the pkgs/by-name directory into an overlay that adds all the defined packages.
# No validity checks are done here.
# Type: Path -> Overlay
baseDirectory:
let
lib = (import ../../outputs.nix {}).lib;
inherit (builtins)
readDir
;
inherit (lib.attrsets)
mapAttrs
mapAttrsToList
mergeAttrsList
;
# Package files for a single shard
# Type: String -> String -> String -> AttrsOf Path
namesForShard = nixFilename: shard: type:
if type != "directory" then
# Ignore all non-directories.
{ }
else
mapAttrs
(name: _: baseDirectory + "/${shard}/${name}/${nixFilename}")
(readDir (baseDirectory + "/${shard}"));
# The attribute set mapping names to the package files defining them
# Type: String -> AttrsOf Path
packageFiles = nixFilename: lib.pipe baseDirectory [
readDir
(mapAttrsToList (namesForShard nixFilename))
mergeAttrsList
# Filter out paths that don't have a ${nixFilename} file
(lib.filterAttrs (_: lib.pathExists))
];
in
self: super:
mapAttrs (name: file:
self.callPackage file { inherit self super; package = super.${name}; }
) (packageFiles "override.nix")
// mapAttrs (name: file:
self.callPackage file { }
) (packageFiles "package.nix")

View file

@ -12,10 +12,11 @@ let
options = (builtins.removeAttrs args attrsToRemove) // {
overlays = (args.overlays or []) ++ [
( import ../overlays/selfExpr.nix { nixpkgsPath = ./impure.nix; } )
# ../.. should be nix store path that represents self in outputs.nix that is gc-rooted by this point
( import ../overlays/selfExpr.nix { nixpkgsPath = "${builtins.toString ../..}/pkgs/top-level/impure.nix"; } )
( import ../overlays/unstable.nix )
( import ../overlays/version-info-fixup.nix { inherit inputs; } )
( import "${inputs.nixpkgs}/pkgs/top-level/by-name-overlay.nix" ../by-name )
( import ./by-name-overlay.nix ../by-name )
];
};
in