added a custom overlay for nixpkgs, moves all of the packages that I maintain into an attribute set 'pkgs.myPkgs' so that my update checker can easily locate them
This commit is contained in:
19
flake.nix
19
flake.nix
@@ -33,16 +33,19 @@
|
|||||||
outputs = { self, home-manager, nixpkgs, nur, nixvim, stylix, ... }@inputs:
|
outputs = { self, home-manager, nixpkgs, nur, nixvim, stylix, ... }@inputs:
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ (import ./overlay/overlay.nix) ];
|
||||||
|
};
|
||||||
username = "pagedmov";
|
username = "pagedmov";
|
||||||
env = import ./env.nix;
|
|
||||||
in {
|
in {
|
||||||
|
inherit pkgs;
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
oganessonHome = home-manager.lib.homeManagerConfiguration {
|
oganessonHome = home-manager.lib.homeManagerConfiguration {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
host = "oganesson";
|
host = "oganesson";
|
||||||
inherit self username env inputs;
|
inherit self username inputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
@@ -58,7 +61,7 @@
|
|||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
host = "oganesson";
|
host = "oganesson";
|
||||||
inherit self env username inputs;
|
inherit self username inputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
@@ -74,7 +77,7 @@
|
|||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
host = "oganesson";
|
host = "oganesson";
|
||||||
inherit self env username inputs;
|
inherit self username inputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
@@ -89,7 +92,7 @@
|
|||||||
oganesson = nixpkgs.lib.nixosSystem {
|
oganesson = nixpkgs.lib.nixosSystem {
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
host = "oganesson";
|
host = "oganesson";
|
||||||
inherit self inputs env username;
|
inherit self inputs username;
|
||||||
};
|
};
|
||||||
inherit system;
|
inherit system;
|
||||||
modules = [
|
modules = [
|
||||||
@@ -103,7 +106,7 @@
|
|||||||
mercury = nixpkgs.lib.nixosSystem {
|
mercury = nixpkgs.lib.nixosSystem {
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
host = "mercury";
|
host = "mercury";
|
||||||
inherit self inputs env username;
|
inherit self inputs username;
|
||||||
};
|
};
|
||||||
inherit system;
|
inherit system;
|
||||||
modules = [
|
modules = [
|
||||||
@@ -117,7 +120,7 @@
|
|||||||
xenon = nixpkgs.lib.nixosSystem {
|
xenon = nixpkgs.lib.nixosSystem {
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
host = "xenon";
|
host = "xenon";
|
||||||
inherit self inputs env username;
|
inherit self inputs username;
|
||||||
};
|
};
|
||||||
inherit system;
|
inherit system;
|
||||||
modules = [
|
modules = [
|
||||||
|
|||||||
@@ -1,74 +1,6 @@
|
|||||||
{ pkgs, self, ... }:
|
{ pkgs, self, ... }:
|
||||||
|
|
||||||
let
|
{
|
||||||
check_updates = pkgs.stdenv.mkDerivation {
|
|
||||||
pname = "pkg_maintenance_check";
|
|
||||||
version = "1.0";
|
|
||||||
src = ./.;
|
|
||||||
buildPhase = ''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
cat > $out/bin/checkupdates.py <<- EOF
|
|
||||||
import os, re, json, requests, subprocess
|
|
||||||
root_dir = '/home/pagedmov/Nix/nixpkgs/pkgs'
|
|
||||||
target_maintainer = 'pagedMov'
|
|
||||||
packages = []
|
|
||||||
pname_pattern = re.compile(r'pname\s*=\s*"([^"]+)"')
|
|
||||||
version_pattern = re.compile(r'version\s*=\s*"([^"]+)"')
|
|
||||||
maintainer_pattern = re.compile(r'maintainers\s*=\s*with\s*lib\.maintainers;\s*\[([^\]]+)\]')
|
|
||||||
repo_pattern = re.compile(r'homepage\s*=\s*"([^"]+)"')
|
|
||||||
for dirpath, _, filenames in os.walk(root_dir):
|
|
||||||
for filename in filenames:
|
|
||||||
file_path = os.path.join(dirpath, filename)
|
|
||||||
try:
|
|
||||||
with open(file_path, 'r', encoding='utf-8') as file:
|
|
||||||
content = file.read()
|
|
||||||
pname_match = pname_pattern.search(content)
|
|
||||||
version_match = version_pattern.search(content)
|
|
||||||
maintainer_match = maintainer_pattern.search(content)
|
|
||||||
repo_match = repo_pattern.search(content)
|
|
||||||
if pname_match and version_match and maintainer_match and repo_match:
|
|
||||||
maintainers = maintainer_match.group(1).split()
|
|
||||||
if target_maintainer in maintainers:
|
|
||||||
package_info = {'pname': pname_match.group(1), 'version': version_match.group(1), 'repo': repo_match.group(1)}
|
|
||||||
packages.append(package_info)
|
|
||||||
except (UnicodeDecodeError, IOError):
|
|
||||||
pass
|
|
||||||
print(json.dumps(packages, indent=2))
|
|
||||||
github_api_template = "https://api.github.com/repos/{owner}/{repo}/releases/latest"
|
|
||||||
updates = []
|
|
||||||
for package in packages:
|
|
||||||
repo_url = package["repo"]
|
|
||||||
current_version = package["version"]
|
|
||||||
if "github.com" in repo_url:
|
|
||||||
owner_repo = repo_url.split("github.com/")[1]
|
|
||||||
if owner_repo.endswith("/"):
|
|
||||||
owner_repo = owner_repo[:-1]
|
|
||||||
owner, repo = owner_repo.split('/')
|
|
||||||
api_url = github_api_template.format(owner=owner, repo=repo)
|
|
||||||
response = requests.get(api_url)
|
|
||||||
if response.status_code == 200:
|
|
||||||
latest_release = response.json()
|
|
||||||
latest_version = latest_release.get("tag_name", "").lstrip('v')
|
|
||||||
if latest_version and latest_version != current_version:
|
|
||||||
updates.append({"pkg": package["pname"], "version": latest_version})
|
|
||||||
else:
|
|
||||||
print(f"{package['pname']} is up to date.\n")
|
|
||||||
else:
|
|
||||||
print(f"Failed to check version for {package['pname']} (HTTP {response.status_code}).\n")
|
|
||||||
else:
|
|
||||||
print(f"Skipping non-GitHub repository for {package['pname']}.\n")
|
|
||||||
if updates:
|
|
||||||
update_string = '''
|
|
||||||
for update in updates:
|
|
||||||
update_string += f" {update['pkg']} -> {update['version']}\n"
|
|
||||||
subprocess.run(["notify-send", "--icon=/home/pagedmov/.sysflake/assets/images/nixos-icon-generic.png", "Maintenance Update", f"Updates found:\n{update_string}"])
|
|
||||||
subprocess.run(["aplay", "-q", "-N", "/home/pagedmov/.sysflake/assets/sound/login.wav"])
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
buildInputs = with pkgs; [ python3Packages.requests ];
|
|
||||||
installPhase = ":";
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
systemd.user = {
|
systemd.user = {
|
||||||
timers = {
|
timers = {
|
||||||
maintenanceCheck = {
|
maintenanceCheck = {
|
||||||
@@ -99,7 +31,7 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
ExecStart = "${pkgs.nix}/bin/nix-shell -p python3Packages.requests --run '${pkgs.python311}/bin/python ${check_updates}/bin/checkupdates.py'";
|
ExecStart = "${pkgs.nix}/bin/nix-shell -p python3Packages.requests --run '${pkgs.python311}/bin/python ${pkgs.myPkgs.check_updates}/bin/checkupdates.py'";
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
71
overlay/check_updates/package.nix
Normal file
71
overlay/check_updates/package.nix
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { } }:
|
||||||
|
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "pkg_maintenance_check";
|
||||||
|
version = "1.0";
|
||||||
|
src = ./.;
|
||||||
|
buildPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cat > $out/bin/checkupdates.py <<- EOF
|
||||||
|
import os, re, json, requests, subprocess
|
||||||
|
flakePath = os.getenv('FLAKEPATH')
|
||||||
|
def nix_eval(expr):
|
||||||
|
try:
|
||||||
|
result = subprocess.run(
|
||||||
|
["nix", "eval", "--json", expr],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
check=True)
|
||||||
|
return json.loads(result.stdout)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Error running 'nix eval' for {expr}: {e}")
|
||||||
|
return {}
|
||||||
|
packages = nix_eval(f"{flakePath}#pkgs.myPkgs")
|
||||||
|
target_maintainer = 'pagedMov'
|
||||||
|
maintained_packages = []
|
||||||
|
for pname in packages.keys():
|
||||||
|
maintainers_info = nix_eval(f"{flakePath}#pkgs.myPkgs.{pname}.meta.maintainers")
|
||||||
|
for maintainer in maintainers_info:
|
||||||
|
if maintainer.get('github') == target_maintainer:
|
||||||
|
# Collect relevant package details
|
||||||
|
version = nix_eval(f"{flakePath}#pkgs.myPkgs.{pname}.version") or "unknown"
|
||||||
|
repo_url = nix_eval(f"{flakePath}#pkgs.myPkgs.{pname}.meta.homepage") or ""
|
||||||
|
maintained_packages.append({
|
||||||
|
'pname': pname,
|
||||||
|
'version': version,
|
||||||
|
'repo': repo_url,
|
||||||
|
'maintainers': maintainers_info
|
||||||
|
})
|
||||||
|
break
|
||||||
|
print(json.dumps(maintained_packages, indent=2))
|
||||||
|
github_api_template = "https://api.github.com/repos/{owner}/{repo}/releases/latest"
|
||||||
|
updates = []
|
||||||
|
for package in maintained_packages:
|
||||||
|
repo_url = package["repo"]
|
||||||
|
current_version = package["version"]
|
||||||
|
if "github.com" in repo_url:
|
||||||
|
owner_repo = repo_url.split("github.com/")[1].rstrip('/')
|
||||||
|
owner, repo = owner_repo.split('/')
|
||||||
|
api_url = github_api_template.format(owner=owner, repo=repo)
|
||||||
|
response = requests.get(api_url)
|
||||||
|
if response.status_code == 200:
|
||||||
|
latest_release = response.json()
|
||||||
|
latest_version = latest_release.get("tag_name", "").lstrip('v')
|
||||||
|
if latest_version and latest_version != current_version:
|
||||||
|
updates.append({"pkg": package["pname"], "version": latest_version})
|
||||||
|
else:
|
||||||
|
print(f"{package['pname']} is up to date.\n")
|
||||||
|
else:
|
||||||
|
print(f"Failed to check version for {package['pname']} (HTTP {response.status_code}).\n")
|
||||||
|
else:
|
||||||
|
print(f"Skipping non-GitHub repository for {package['pname']}.\n")
|
||||||
|
if updates:
|
||||||
|
update_string = '\n'.join([f" {update['pkg']} -> {update['version']}" for update in updates])
|
||||||
|
subprocess.run(["notify-send", "--icon=/home/pagedmov/.sysflake/assets/images/nixos-icon-generic.png",
|
||||||
|
"Maintenance Update", f"Package updates found:\n{update_string}"])
|
||||||
|
subprocess.run(["aplay", "-q", "-N", "/home/pagedmov/.sysflake/assets/sound/login.wav"])
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
buildInputs = with pkgs; [ python3Packages.requests ];
|
||||||
|
installPhase = ":";
|
||||||
|
}
|
||||||
6
overlay/overlay.nix
Normal file
6
overlay/overlay.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
self: super: {
|
||||||
|
myPkgs = {
|
||||||
|
tinyfetch = super.callPackage ./tinyfetch/package.nix {};
|
||||||
|
check_updates = super.callPackage ./check_updates/package.nix {};
|
||||||
|
};
|
||||||
|
}
|
||||||
47
overlay/tinyfetch/package.nix
Normal file
47
overlay/tinyfetch/package.nix
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
stdenv,
|
||||||
|
fetchFromGitHub,
|
||||||
|
lib,
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
pagedMov = {
|
||||||
|
email = "kylerclay@proton.me";
|
||||||
|
github = "pagedMov";
|
||||||
|
githubId = 19557376;
|
||||||
|
name = "Kyler Clay";
|
||||||
|
keys = [ { fingerprint = "784B 3623 94E7 8F11 0B9D AE0F 56FD CFA6 2A93 B51E"; } ];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "tinyfetch";
|
||||||
|
version = "0.2";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "abrik1";
|
||||||
|
repo = "tinyfetch";
|
||||||
|
rev = "refs/tags/0.2";
|
||||||
|
hash = "sha256-nuC7Xtfg7rf6/IDhUKT2JZD9V0Hl/welNAFDJYJKwmA=";
|
||||||
|
};
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
$CC src/tinyfetch.c -o tinyfetch
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
install -Dm755 tinyfetch -t $out/bin
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Simple fetch in C which is tiny and fast";
|
||||||
|
homepage = "https://github.com/abrik1/tinyfetch";
|
||||||
|
license = lib.licenses.mit;
|
||||||
|
mainProgram = "tinyfetch";
|
||||||
|
maintainers = [ pagedMov ];
|
||||||
|
platforms = lib.platforms.unix;
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user