Restructure flake.nix and add JHelioviewer package

This commit is contained in:
2024-07-06 16:50:32 -05:00
parent 4424978387
commit d8d07896fe
6 changed files with 319 additions and 232 deletions

55
flake.lock generated
View File

@@ -1,17 +1,5 @@
{
"nodes": {
"currentSystem": {
"locked": {
"lastModified": 1717805060,
"narHash": "sha256-jgZROz6KZg2bOy4PGGd/vzpmn7v22+C+2Ivwfk26OXo=",
"path": "/etc/nixos/hostname",
"type": "path"
},
"original": {
"path": "/etc/nixos/hostname",
"type": "path"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
@@ -37,11 +25,11 @@
]
},
"locked": {
"lastModified": 1718530513,
"narHash": "sha256-BmO8d0r+BVlwWtMLQEYnwmngqdXIuyFzMwvmTcLMee8=",
"lastModified": 1720042825,
"narHash": "sha256-A0vrUB6x82/jvf17qPCpxaM+ulJnD8YZwH9Ci0BsAzE=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "a1fddf0967c33754271761d91a3d921772b30d0e",
"rev": "e1391fb22e18a36f57e6999c7a9f966dc80ac073",
"type": "github"
},
"original": {
@@ -58,11 +46,11 @@
]
},
"locked": {
"lastModified": 1719180626,
"narHash": "sha256-vZAzm5KQpR6RGple1dzmSJw5kPivES2heCFM+ZWkt0I=",
"lastModified": 1720045378,
"narHash": "sha256-lmE7B+QXw7lWdBu5GQlUABSpzPk3YBb9VbV+IYK5djk=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "6b1f90a8ff92e81638ae6eb48cd62349c3e387bb",
"rev": "0a30138c694ab3b048ac300794c2eb599dc40266",
"type": "github"
},
"original": {
@@ -73,11 +61,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1718983919,
"narHash": "sha256-+1xgeIow4gJeiwo4ETvMRvWoircnvb0JOt7NS9kUhoM=",
"lastModified": 1719468428,
"narHash": "sha256-vN5xJAZ4UGREEglh3lfbbkIj+MPEYMuqewMn4atZFaQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "90338afd6177fc683a04d934199d693708c85a3b",
"rev": "1e3deb3d8a86a870d925760db1a5adecc64d329d",
"type": "github"
},
"original": {
@@ -89,11 +77,11 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1718835956,
"narHash": "sha256-wM9v2yIxClRYsGHut5vHICZTK7xdrUGfrLkXvSuv6s4=",
"lastModified": 1719956923,
"narHash": "sha256-nNJHJ9kfPdzYsCOlHOnbiiyKjZUW5sWbwx3cakg3/C4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "dd457de7e08c6d06789b1f5b88fc9327f4d96309",
"rev": "706eef542dec88cc0ed25b9075d3037564b2d164",
"type": "github"
},
"original": {
@@ -105,11 +93,11 @@
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1719099622,
"narHash": "sha256-YzJECAxFt+U5LPYf/pCwW/e1iUd2PF21WITHY9B/BAs=",
"lastModified": 1719663039,
"narHash": "sha256-tXlrgAQygNIy49LDVFuPXlWD2zTQV9/F8pfoqwwPJyo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5e8e3b89adbd0be63192f6e645e0a54080004924",
"rev": "4a1e673523344f6ccc84b37f4413ad74ea19a119",
"type": "github"
},
"original": {
@@ -121,11 +109,11 @@
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1719075281,
"narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=",
"lastModified": 1719848872,
"narHash": "sha256-H3+EC5cYuq+gQW8y0lSrrDZfH71LB4DAf+TDFyvwCNA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af",
"rev": "00d80d13810dbfea8ab4ed1009b09100cca86ba8",
"type": "github"
},
"original": {
@@ -137,7 +125,6 @@
},
"root": {
"inputs": {
"currentSystem": "currentSystem",
"flake-utils": "flake-utils",
"home-manager-stable": "home-manager-stable",
"home-manager-unstable": "home-manager-unstable",
@@ -152,11 +139,11 @@
"nixpkgs-stable": "nixpkgs-stable_2"
},
"locked": {
"lastModified": 1719111739,
"narHash": "sha256-kr2QzRrplzlCP87ddayCZQS+dhGW98kw2zy7+jUXtF4=",
"lastModified": 1719873517,
"narHash": "sha256-D1dxZmXf6M2h5lNE1m6orojuUawVPjogbGRsqSBX+1g=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "5e2e9421e9ed2b918be0a441c4535cfa45e04811",
"rev": "a11224af8d824935f363928074b4717ca2e280db",
"type": "github"
},
"original": {

389
flake.nix
View File

@@ -2,8 +2,6 @@
description = "NixOS configuration";
inputs = {
currentSystem.url = "path:/etc/nixos/hostname";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
@@ -21,7 +19,6 @@
};
outputs = inputs@{ self
, currentSystem
, nixpkgs-stable
, nixpkgs-unstable
, home-manager-stable
@@ -29,207 +26,211 @@
, flake-utils
, sops-nix
, ...
}: let
inherit (self) outputs;
inherit (currentSystem) hostname;
}:
let
inherit (self) outputs;
lib = nixpkgs-stable.lib;
overlays = import ./overlays { inherit inputs; };
utils = import ./utils;
overlays = import ./overlays { inherit inputs; };
utils = import ./utils;
configs."ankaa" = {
system = "x86_64-linux";
common.nixpkgs = "unstable";
configs = [
{
hostname = "ankaa";
system = "x86_64-linux";
nixpkgs = nixpkgs-unstable;
home-manager = home-manager-unstable;
openssh = {
enable = true;
port = 2222;
};
options = {
openssh = {
enable = true;
port = 2222;
};
backup = {
enable = true;
user = "eesim";
paths = [ "/home/eesim" ];
repo = "rf030789@rf030789.repo.borgbase.com:repo";
excludes = [
"/home/eesim/.local/share/Steam/steamapps/common"
"/home/eesim/.cache"
];
passphrase = "/home/eesim/.ssh/borgbase_passphrase";
key = "/home/eesim/.ssh/id_ed25519_borgbase";
repeat = "daily";
};
backup = {
enable = true;
user = "eesim";
paths = [ "/home/eesim" ];
repo = "rf030789@rf030789.repo.borgbase.com:repo";
excludes = [
"/home/eesim/.local/share/Steam/steamapps/common"
"/home/eesim/.cache"
];
passphrase = "/home/eesim/.ssh/borgbase_passphrase";
key = "/home/eesim/.ssh/id_ed25519_borgbase";
repeat = "daily";
};
audio = {
pipewire.enable = true;
music.enable = true;
tools = {
helvum = true;
easyeffects = true;
};
};
audio = {
pipewire.enable = true;
music.enable = true;
tools = {
helvum = true;
easyeffects = true;
};
};
gui = {
enable = true;
protonmail = true;
matrix = true;
gtk = false;
gui = {
enable = true;
protonmail = true;
matrix = true;
gtk = false;
sway = {
enable = true;
desktop = true;
};
monitors = pkgs.lib.mkMerge [
(utils.mkMonitor {
monitor = "DP-2";
resolution = "3440x1440";
refreshRate = 144;
x = 1920;
wallpaper = "ship_moon.png";
})
(utils.mkMonitor {
monitor = "HDMI-A-1";
resolution = "1920x1080";
refreshRate = 75;
})
];
};
games = {
enable = true;
lutris.enable = true;
minecraft.enable = true;
};
common.nil.enable = true;
networking = {
wireguard.enable = true;
};
};
configs."alpheratz" = {
system = "x86_64-linux";
common.nixpkgs = "unstable";
laptop = {
powersave.enable = true;
backlight.enable = true;
};
audio = {
pipewire.enable = true;
music.enable = true;
};
gui = {
enable = true;
protonmail = true;
matrix = true;
sway = {
enable = true;
desktop = false;
};
monitors = utils.mkMonitor {
monitor = "eDP-1";
resolution = "1920x1200";
refreshRate = 60;
};
};
common.nil.enable = true;
networking = {
wireguard.enable = true;
};
};
configs."diphda" = {
system = "x86_64-linux";
common.nixpkgs = "stable";
openssh.enable = true;
networking = {
firewall = {
allowedTCPPorts = [ 80 443 4533 7878 8096 8089 8902 8989 9000 9696 11112 24454 25565 25600 ];
};
};
};
currentConfig = configs."${hostname}";
system = currentConfig.system;
nixpkgs = if currentConfig.common.nixpkgs == "unstable" then
nixpkgs-unstable
else
nixpkgs-stable;
home-manager = if currentConfig.common.nixpkgs == "unstable" then
home-manager-unstable
else
home-manager-stable;
pkgs = import nixpkgs {
inherit system;
overlays = with overlays; [ gamescope ];
config.allowUnfree = true;
};
systemConfig = if builtins.pathExists (./. + "/hosts/${hostname}/system.nix") then
(./. + "/hosts/${hostname}/system.nix")
else
./hosts/default/system.nix;
homeConfig = if builtins.pathExists (./. + "/hosts/${hostname}/home.nix") then
(./. + "/hosts/${hostname}/home.nix")
else
./hosts/default/home.nix;
in {
nixosConfigurations = {
"${hostname}" = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit (outputs) localPackages;
inherit pkgs;
};
modules = [
{
networking.hostName = hostname;
simmer = currentConfig;
}
systemConfig
(./. + "/hosts/${hostname}/hardware-configuration.nix")
sops-nix.nixosModules.sops
(import ./modules/nix)
(import ./modules/options)
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit utils;
systemConfig = configs."${hostname}";
sway = {
enable = true;
desktop = true;
};
home-manager.users.eesim = import homeConfig;
}
];
};
};
localPackages = pkgs.lib.genAttrs flake-utils.lib.defaultSystems (system:
{
kickoff-dot-desktop = pkgs.callPackage ./pkgs/kickoff-dot-desktop.nix {};
gamescope-old = pkgs.callPackage ./pkgs/gamescope-old {};
gamescope-dbg = pkgs.callPackage ./pkgs/gamescope-dbg {};
monitors = lib.mkMerge [
(utils.mkMonitor {
monitor = "DP-2";
resolution = "3440x1440";
refreshRate = 144;
x = 1920;
wallpaper = "ship_moon.png";
})
(utils.mkMonitor {
monitor = "HDMI-A-1";
resolution = "1920x1080";
refreshRate = 75;
})
];
};
games = {
enable = true;
lutris.enable = true;
minecraft.enable = true;
};
common.nil.enable = true;
networking = {
wireguard.enable = true;
};
};
}
{
hostname = "alpheratz";
system = "x86_64-linux";
nixpkgs = nixpkgs-unstable;
home-manager = home-manager-unstable;
options = {
laptop = {
powersave.enable = true;
backlight.enable = true;
};
audio = {
pipewire.enable = true;
music.enable = true;
};
gui = {
enable = true;
protonmail = true;
matrix = true;
sway = {
enable = true;
desktop = false;
};
monitors = utils.mkMonitor {
monitor = "eDP-1";
resolution = "1920x1200";
refreshRate = 60;
};
};
common.nil.enable = true;
networking = {
wireguard.enable = true;
};
};
}
{
hostname = "diphda";
system = "x86_64-linux";
nixpkgs = nixpkgs-stable;
home-manager = home-manager-stable;
options = {
openssh.enable = true;
networking = {
firewall = {
allowedTCPPorts = [ 80 443 4533 7878 8096 8089 8902 8989 9000 9696 11112 24454 25565 25600 ];
};
};
};
}
];
in {
nixosConfigurations = builtins.listToAttrs (map (config:
let
inherit (config) nixpkgs home-manager system hostname;
pkgs = import nixpkgs {
inherit system;
overlays = with overlays; [ gamescope ];
};
localPackages = pkgs.lib.genAttrs flake-utils.lib.defaultSystems (system: {
kickoff-dot-desktop = pkgs.callPackage ./pkgs/kickoff-dot-desktop.nix {};
gamescope-old = pkgs.callPackage ./pkgs/gamescope-old {};
gamescope-dbg = pkgs.callPackage ./pkgs/gamescope-dbg {};
jhelioviewer = pkgs.callPackage ./pkgs/jhelioviewer.nix {};
}
);
systemConfig = if builtins.pathExists (./. + "/hosts/${hostname}/system.nix") then
(./. + "/hosts/${hostname}/system.nix")
else
./hosts/default/system.nix;
homeConfig = if builtins.pathExists (./. + "/hosts/${hostname}/home.nix") then
(./. + "/hosts/${hostname}/home.nix")
else
./hosts/default/home.nix;
in
{
name = config.hostname;
value = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit localPackages;
inherit pkgs;
};
modules = [
{
networking.hostName = hostname;
simmer = config.options;
}
systemConfig
(./. + "/hosts/${hostname}/hardware-configuration.nix")
sops-nix.nixosModules.sops
(import ./modules/nix)
(import ./modules/options)
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit utils;
systemConfig = config.options;
};
home-manager.users.eesim = import homeConfig;
}
];
};
})
configs
);
};
}

View File

@@ -6,6 +6,7 @@
lib,
config,
pkgs,
localPackages,
...
}: {
@@ -30,6 +31,8 @@
secrets."wireguard/preshared" = {};
};
environment.systemPackages = [ localPackages.x86_64-linux.jhelioviewer ];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.xbootldrMountPoint = "/boot";
@@ -51,7 +54,7 @@
listenPort = 51820;
privateKeyFile = "/run/secrets/wireguard/private";
dns = [ "192.168.1.1" ];
autostart = false;
autostart = true;
peers = [
{

View File

@@ -16,11 +16,30 @@ in
services.swayidle = {
enable = true;
timeouts = [
{
(mkIf gui.sway.desktop {
timeout = 600;
command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'";
resumeCommand = "${pkgs.sway}/bin/swaymsg 'output * dpms on'";
}
})
(mkIf (!gui.sway.desktop) {
timeout = 300;
command = "${pkgs.swaylock}/bin/swaylock -f -c 000000";
})
(mkIf (!gui.sway.desktop) {
timeout = 420;
command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'";
resumeCommand = "${pkgs.sway}/bin/swaymsg 'output * dpms on'";
})
(mkIf (!gui.sway.desktop) {
timeout = 600;
command = "systemctl suspend";
})
];
events = [
(mkIf (!gui.sway.desktop) {
event = "before-sleep";
command = "${pkgs.swaylock}/bin/swaylock -f -c 000000";
})
];
};

View File

@@ -33,6 +33,9 @@ in
services.gnome.gnome-keyring.enable = mkIf cfg.secrets true;
services.dbus.packages = mkIf cfg.secrets [ pkgs.gnome.seahorse ];
# Remove when nixpkgs issue 143365 is fixed
security.pam.services.swaylock = mkIf (!cfg.sway.desktop) {};
xdg.portal.config.common = [ "wlr" "gtk" ];
programs.thunar.enable = true;

74
pkgs/jhelioviewer.nix Normal file
View File

@@ -0,0 +1,74 @@
{ lib
, stdenv
, jdk
, jre
, ant
, jogl
, fetchFromGitHub
, makeDesktopItem
, copyDesktopItems
, stripJavaArchivesHook
, makeWrapper
, ...
}:
stdenv.mkDerivation {
name = "JHelioviewer";
src = fetchFromGitHub {
owner = "Helioviewer-Project";
repo = "JHelioviewer-SWHV";
rev = "537b60bbf4c40e46b98d7a1c0167f3c943e73cd2";
hash = "sha256-LBiywlXAgMifn6ov04CwEnfhSWskSzIy5Cs3NeL90Ts=";
};
nativeBuildInputs = [
jdk
ant
stripJavaArchivesHook
makeWrapper
copyDesktopItems
];
buildPhase = ''
runHook preBuild
ant
runHook postBuild
'';
desktopItems = [
(makeDesktopItem {
name = "jhelioviewer";
desktopName = "JHelioviewer";
exec = "jhelioviewer";
comment = "A visualization tool for solar physics data based on the JPEG 2000 image compression standard, and part of the open source ESA/NASA Helioviewer Project";
icon = "hvLogo";
})
];
installPhase = ''
runHook preInstall
mkdir -p $out/share/java/
mkdir -p $out/share/java/lib
install -Dm644 JHelioviewer.jar $out/share/java/
cp -r lib/* $out/share/java/lib/
rm $out/share/java/lib/jogl/*.jar
cp -v ${jogl}/share/java/jogl*.jar ${jogl}/share/java/glue*.jar $out/share/java/lib/jogl
mkdir $out/bin
makeWrapper ${jre}/bin/java $out/bin/jhelioviewer \
--add-flags "-cp $out/share/java/JHelioviewer.jar" \
--add-flags "--add-exports java.desktop/sun.awt=ALL-UNNAMED" \
--add-flags "--add-exports java.desktop/sun.swing=ALL-UNNAMED" \
--add-flags "org.helioviewer.jhv.JHelioviewer"
mkdir -p $out/share/icons
cp -v docs/hvLogo.png $out/share/icons/
runHook postInstall
'';
}