mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-23 15:10:44 -06:00
Compare commits
6 commits
3e0609d1f8
...
e1799718b9
Author | SHA1 | Date | |
---|---|---|---|
e1799718b9 | |||
6d2146a4f3 | |||
ea8099e184 | |||
a559ac1c79 | |||
b66236553f | |||
c450271582 |
18 changed files with 545 additions and 139 deletions
64
flake.lock
64
flake.lock
|
@ -20,11 +20,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1725199881,
|
||||
"narHash": "sha256-jsmipf/u1GFZE5tBUkr56CHMN6VpUWCAjfLIhvQijU0=",
|
||||
"lastModified": 1725753098,
|
||||
"narHash": "sha256-/NO/h/qD/eJXAQr/fHA4mdDgYsNT9thHQ+oT6KPi2ac=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "aquamarine",
|
||||
"rev": "f8a687dd29ff019657498f1bd14da2fbbf0e604b",
|
||||
"rev": "e4a13203112a036fc7f437d391c7810f3dd5ab52",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -323,11 +323,11 @@
|
|||
"xdph": "xdph"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1725976150,
|
||||
"narHash": "sha256-Dv4XEWRcVFZhBDbj11/zuuXyf7TGHFVU1IGH9W/yPX8=",
|
||||
"lastModified": 1726071051,
|
||||
"narHash": "sha256-eZPhLQ8DM8AsP+zM1KmUzxWQaiTpOUbFS1xeOyjgwvg=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "155d44016d0cb11332c454db73d59030cdbd7b13",
|
||||
"revCount": 5209,
|
||||
"rev": "8b9e385943d1a9fd0f8c6070fa1eae507ae26145",
|
||||
"revCount": 5213,
|
||||
"submodules": true,
|
||||
"type": "git",
|
||||
"url": "https://github.com/hyprwm/Hyprland/"
|
||||
|
@ -399,11 +399,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1725188252,
|
||||
"narHash": "sha256-yBH8c4GDaEAtBrh+BqIlrx5vp6gG/Gu8fQQK63KAQgs=",
|
||||
"lastModified": 1725997860,
|
||||
"narHash": "sha256-d/rZ/fHR5l1n7PeyLw0StWMNLXVU9c4HFyfskw568so=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprlang",
|
||||
"rev": "c12ab785ce1982f82594aff03b3104c598186ddd",
|
||||
"rev": "dfeb5811dd6485490cce18d6cc1e38a055eea876",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -504,11 +504,11 @@
|
|||
"lix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1725927421,
|
||||
"narHash": "sha256-tiQ9OxiuTb/02xEU2ceo9MIxWBS5Rm/IAhv6QshH8K0=",
|
||||
"rev": "cc183fdbc14ce105a5661d646983f791978b9d5c",
|
||||
"lastModified": 1726016547,
|
||||
"narHash": "sha256-tB4Y3Rrv67ZdEo3HJzxYL5XX9wqtvWwIX1z8k399W0s=",
|
||||
"rev": "24db81eaf28259ab8f8334ccd6368673a26ed422",
|
||||
"type": "tarball",
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/cc183fdbc14ce105a5661d646983f791978b9d5c.tar.gz?rev=cc183fdbc14ce105a5661d646983f791978b9d5c"
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/24db81eaf28259ab8f8334ccd6368673a26ed422.tar.gz?rev=24db81eaf28259ab8f8334ccd6368673a26ed422"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
|
@ -707,11 +707,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1725103162,
|
||||
"narHash": "sha256-Ym04C5+qovuQDYL/rKWSR+WESseQBbNAe5DsXNx5trY=",
|
||||
"lastModified": 1725983898,
|
||||
"narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "12228ff1752d7b7624a54e9c1af4b222b3c1073b",
|
||||
"rev": "1355a0cbfeac61d785b7183c0caaec1f97361b43",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -744,11 +744,11 @@
|
|||
"nixpkgs": "nixpkgs_6"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1725981791,
|
||||
"narHash": "sha256-+4dwaoIrnubM29MK8BW4S2mdKwdlCF1svtO0hQ443X0=",
|
||||
"lastModified": 1726058240,
|
||||
"narHash": "sha256-p74soeV48Sry7+wOxDJ8Gqx3JT26lH9AY4+slpJemyw=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs-wayland",
|
||||
"rev": "90046312d6c074e7b941b7ea9c4e54f4d416e5da",
|
||||
"rev": "5d6271a06b79364aa838cdc68c5852d383b17236",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -791,11 +791,11 @@
|
|||
},
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1725634671,
|
||||
"narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=",
|
||||
"lastModified": 1725983898,
|
||||
"narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c",
|
||||
"rev": "1355a0cbfeac61d785b7183c0caaec1f97361b43",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -823,11 +823,11 @@
|
|||
},
|
||||
"nixpkgs_6": {
|
||||
"locked": {
|
||||
"lastModified": 1725634671,
|
||||
"narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=",
|
||||
"lastModified": 1725983898,
|
||||
"narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c",
|
||||
"rev": "1355a0cbfeac61d785b7183c0caaec1f97361b43",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -900,11 +900,11 @@
|
|||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1725957803,
|
||||
"narHash": "sha256-qBG8DEmc9aOLr/WBtsuOB5QKEDxK2bDy4dq3X686xdo=",
|
||||
"lastModified": 1726002278,
|
||||
"narHash": "sha256-INEUQt5tQkmQtHv+//9+FGFOet2IEJPg/31y8qtsCqs=",
|
||||
"owner": "roc-lang",
|
||||
"repo": "roc",
|
||||
"rev": "2936a37a1c54cb4cb10003c3b7e43a4772bbccf9",
|
||||
"rev": "3d9c4673af25349be43e0e8e703a0f4b36176577",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1162,11 +1162,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1725228143,
|
||||
"narHash": "sha256-kbSiPA5oXiz1+1eVoRslMi5wylHD6SDT8dS9eZAxXAM=",
|
||||
"lastModified": 1726046979,
|
||||
"narHash": "sha256-6SEsjurq9cdTkITA6d49ncAJe4O/8CgRG5/F//s6Xh8=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "xdg-desktop-portal-hyprland",
|
||||
"rev": "11e15b437e7efc39e452f36e15a183225d6bfa39",
|
||||
"rev": "e695669fd8e1d1be9eaae40f35e00f8bd8b64c18",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -3,23 +3,21 @@ let
|
|||
lib = nixpkgs.lib.extend (import ./extended.nix inputs);
|
||||
|
||||
inherit (builtins) mapAttrs readDir listToAttrs;
|
||||
inherit (lib) genAttrs pkgFromSystem pkgsFromSystem;
|
||||
inherit (lib) genAttrs pkgFromSystem pkgsFromSystem loadOverlays;
|
||||
|
||||
inherit (import ./find-modules.nix { inherit lib; }) findModulesList;
|
||||
inherit (import ./generators.nix { inherit lib self inputs; }) mkIso mkSystem;
|
||||
#supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
|
||||
forAllSystems =
|
||||
f:
|
||||
fn:
|
||||
genAttrs supportedSystems (
|
||||
system:
|
||||
f (
|
||||
fn (
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
inputs.nim2nix.overlays.default
|
||||
(import ../overlays/nimble { inherit inputs; })
|
||||
];
|
||||
overlays = (import ../overlays { inherit inputs loadOverlays; });
|
||||
}
|
||||
)
|
||||
);
|
||||
|
@ -42,6 +40,7 @@ let
|
|||
default = oizys-nim;
|
||||
oizys-nim = pkgs.callPackage ../pkgs/oizys-nim { };
|
||||
oizys-go = pkgs.callPackage ../pkgs/oizys { };
|
||||
nimlangserver = pkgs.callPackage ../pkgs/nimlangserver { };
|
||||
iso = mkIso.config.system.build.isoImage;
|
||||
roc = (pkgsFromSystem pkgs.system "roc").full;
|
||||
}
|
||||
|
@ -61,13 +60,13 @@ let
|
|||
];
|
||||
};
|
||||
});
|
||||
checks = forAllSystems (
|
||||
pkgs:
|
||||
import ./checks.nix {
|
||||
inherit inputs lib self;
|
||||
system = pkgs.system;
|
||||
}
|
||||
);
|
||||
# checks = forAllSystems (
|
||||
# pkgs:
|
||||
# import ./checks.nix {
|
||||
# inherit inputs lib self;
|
||||
# system = pkgs.system;
|
||||
# }
|
||||
# );
|
||||
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
|
||||
};
|
||||
in
|
||||
|
|
|
@ -3,8 +3,11 @@ let
|
|||
inherit (builtins)
|
||||
listToAttrs
|
||||
substring
|
||||
filter
|
||||
replaceStrings
|
||||
map
|
||||
filter
|
||||
attrNames
|
||||
readDir
|
||||
;
|
||||
inherit (final)
|
||||
concatStringsSep
|
||||
|
@ -106,6 +109,12 @@ let
|
|||
pkg = pkgFromSystem system;
|
||||
};
|
||||
|
||||
loadOverlays =
|
||||
inputs: dir: readDir dir
|
||||
|> attrNames
|
||||
|> filter (f: f != "default.nix")
|
||||
|> map (f: import (../overlays + "/${f}") { inherit inputs; });
|
||||
|
||||
in
|
||||
{
|
||||
inherit
|
||||
|
@ -125,5 +134,6 @@ in
|
|||
overlayFrom
|
||||
flakeFromSystem
|
||||
listify
|
||||
loadOverlays
|
||||
;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ let
|
|||
nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
../overlays
|
||||
../modules/oizys.nix
|
||||
inputs.lix-module.nixosModules.default
|
||||
inputs.hyprland.nixosModules.default
|
||||
|
|
|
@ -7,15 +7,16 @@
|
|||
let
|
||||
inherit (lib) mkIfIn;
|
||||
cfg = config.oizys.languages;
|
||||
nimlangserver = pkgs.callPackage ../../pkgs/nimlangserver { };
|
||||
in
|
||||
{
|
||||
config = mkIfIn "nim" cfg {
|
||||
environment.systemPackages = with pkgs; [
|
||||
environment.systemPackages =
|
||||
with pkgs;
|
||||
[
|
||||
nim
|
||||
|
||||
nim-atlas
|
||||
nimble
|
||||
nimlangserver
|
||||
];
|
||||
]
|
||||
++ [ nimlangserver ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,15 +10,14 @@ let
|
|||
inherit (pkgs) python3Packages;
|
||||
# llm-ollama = python3Packages.callPackage ./llm-plugins/llm-ollama { };
|
||||
llm-claude3 = python3Packages.callPackage ./llm-plugins/llm-claude-3 { };
|
||||
llm = (
|
||||
pkgs.llm.withPlugins [
|
||||
# llm-ollama
|
||||
llm-claude3
|
||||
]
|
||||
);
|
||||
in
|
||||
|
||||
mkOizysModule config "llm" {
|
||||
# services.ollama = enabled;
|
||||
environment.systemPackages = [ llm ];
|
||||
environment.systemPackages = with pkgs; [
|
||||
(python3.withPackages (ps: [
|
||||
ps.llm
|
||||
llm-claude3
|
||||
]))
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{
|
||||
inputs,
|
||||
lib,
|
||||
self,
|
||||
hostName,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption;
|
||||
inherit (lib) mkEnableOption mkOption loadOverlays;
|
||||
in
|
||||
{
|
||||
imports = with self.nixosModules; [
|
||||
|
@ -54,5 +55,6 @@ in
|
|||
config = {
|
||||
networking.hostName = hostName;
|
||||
time.timeZone = "US/Central";
|
||||
nixpkgs.overlays = import ../overlays { inherit inputs loadOverlays; };
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,30 +1,11 @@
|
|||
{ inputs, ... }:
|
||||
let
|
||||
inherit (builtins)
|
||||
map
|
||||
filter
|
||||
attrNames
|
||||
readDir
|
||||
;
|
||||
# execute and import all overlay files in the current
|
||||
# directory with the given args
|
||||
# overlays =
|
||||
# map
|
||||
# (f: (import (./. + "/${f}") { inherit inputs; }))
|
||||
# (filter (f: f != "default.nix") (attrNames (readDir ./.)));
|
||||
overlays =
|
||||
readDir ./.
|
||||
|> attrNames
|
||||
|> filter (f: f != "default.nix")
|
||||
|> map (f: import (./. + "/${f}") { inherit inputs; });
|
||||
in
|
||||
{
|
||||
nixpkgs.overlays = overlays ++ [
|
||||
{ inputs, loadOverlays }:
|
||||
(loadOverlays inputs ./.)
|
||||
++ [
|
||||
inputs.nim2nix.overlays.default # adds buildNimPackage
|
||||
(final: _prev: {
|
||||
stable = import inputs.stable {
|
||||
system = final.system;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
{ ... }:
|
||||
(final: prev: {
|
||||
nim-atlas = prev.nim-atlas.overrideNimAttrs {
|
||||
version = "unstable";
|
||||
src = final.fetchFromGitHub {
|
||||
owner = "nim-lang";
|
||||
repo = "atlas";
|
||||
rev = "cbba9fa77fa837931bf3c58e20c1f8cb15a22919";
|
||||
hash = "sha256-TsZ8TriVuKEY9/mV6KR89eFOgYrgTqXmyv/vKu362GU=";
|
||||
};
|
||||
};
|
||||
})
|
15
pkgs/nimlangserver/default.nix
Normal file
15
pkgs/nimlangserver/default.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{ fetchFromGitHub, buildNimPackage }:
|
||||
buildNimPackage{
|
||||
pname = "nimlangserver";
|
||||
version = "unstable";
|
||||
src = fetchFromGitHub {
|
||||
owner = "daylinmorgan";
|
||||
repo = "langserver";
|
||||
rev = "26b333d0c8d62ba947a9ce9fbd59a7a77766872c";
|
||||
# rev = "v${version}";
|
||||
hash = "sha256-XFgA0yOfE34+bZxBgOdoK+5CWhxvppzl8QSQx1TTPpQ=";
|
||||
};
|
||||
|
||||
doCheck = false;
|
||||
lockFile = ./lock.json;
|
||||
}
|
242
pkgs/nimlangserver/lock.json
Normal file
242
pkgs/nimlangserver/lock.json
Normal file
|
@ -0,0 +1,242 @@
|
|||
{
|
||||
"depends": [
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/jvk4kr8wws3dbjqnlag2zcysg0d7xnhz-nim-chronos-c04576d",
|
||||
"rev": "c04576d829b8a0a1b12baaa8bc92037501b3a4a0",
|
||||
"sha256": "0plwammxi4iis59p2416g7420f5fx38jziwhmi082c5lm2x658x9",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-chronos",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"chronos"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/rxh6hjns335dl5zn13dl78hlj6ign33m-nim-http-utils-8b88ad6",
|
||||
"rev": "8b88ad6dd9a6326c29f82067800c483d9410d873",
|
||||
"sha256": "1c20yhzm7c69xkcdzxwbm8ldid565nrmvgr5jk3g6cghh6z9b63n",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-http-utils",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"httputils"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/ngj2jlgi2ygv3xvnqvhlpws2s069fh6c-nim-stint-7c81df9",
|
||||
"rev": "7c81df9adc80088f46a4c2b8bf2a46c26fab057c",
|
||||
"sha256": "0gl8hxk3a29p5f2l3x5v3hscbydnwy8470bl9xjsawysbpa41jq0",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-stint",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"stint"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/fvqlv9l67gdbvdq48w76y7dm48s52viw-nim-unittest2-e96f321",
|
||||
"rev": "e96f3215030cbfa13abc2f5827069b6f8ba87e38",
|
||||
"sha256": "0q919mswsspk3fdhb9a742y7yv0pk14yc965afx2jza57m4fw2a2",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-unittest2",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"unittest2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/ggzfksc7mbfllfdr2va5rmyx757c7nfx-nim-websock-63bcc29",
|
||||
"rev": "63bcc2902d884c63101e144555ad99421734a70a",
|
||||
"sha256": "0rxdz62pns7ywwzh4r1pjj9qyhx7djj06y5yhf83j7dc30qi7wp2",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-websock",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"websock"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/4q5lil0j6wdxjbkk4nbwnvz0swhxph4v-nim-serialization-298a955",
|
||||
"rev": "298a9554a885b2df59737bb3461aac8d0d339724",
|
||||
"sha256": "1skh778gkml33n0pz7s8fxybdn2rqg2hg10nyp8jip9x6rbpgz6g",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-serialization",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"serialization"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/1k3vziq26ynmmm9j9savsfm8d7glmrax-nim-stew-d4634c5",
|
||||
"rev": "d4634c5405ac188e7050d348332edb6c3b09a527",
|
||||
"sha256": "15ii11644vxs55jix64krg8h0ninnhlgqnc7klmskycbcr4a1xgh",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-stew",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"stew"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/3x156nly2vr6nixgw1zk5jp5n6bgi6rk-nim-faststreams-dbc4a95",
|
||||
"rev": "dbc4a95df60238157dcf286f6125188cb72f37c1",
|
||||
"sha256": "1zvh1lgjmszdd074993qkj01w2v7fjxcawjf7iplwq0rvjpszdy0",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-faststreams",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"faststreams"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/7k5blrxbh2zzsxrmz54l5i6v6dj4mp3g-with-91c51ec",
|
||||
"rev": "91c51ec1051bf0cb518cf9bb78114e2a84b03da7",
|
||||
"sha256": "170hfdc2z2qp9cxgvpqswzr4bmzljybh4lnn0k5kganwvf0ffz9p",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/zevv/with",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"with"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/jw9y4cm15y80h3v9xjz5s1r0rnyi5x4i-nim-testutils-e4fb95c",
|
||||
"rev": "e4fb95cbe36ad1e231661c922da04b81e0ffeed9",
|
||||
"sha256": "0gqhag91f8dkdv0v2mg6pz5q6afl70bbnk628i52p4wsi4bl49jj",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-testutils",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"testutils"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/sskmpq7fqax2x2wydb1lhyac4ikx5p6p-nim-results-57b2392",
|
||||
"rev": "57b2392ad69849e3e2d02b74a8a0feee2c3d9570",
|
||||
"sha256": "1wma3dhrrdfxn05ds6yiv9mj071czv90x06bm7f5rslzk0s7m1af",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/arnetheduck/nim-results",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"results"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/06gaz1ks9rc13bxr7wkig4sfiz0mb3xw-nim-json-rpc-e27c10a",
|
||||
"rev": "e27c10ad4172e67f71a78044f53de073e7401390",
|
||||
"sha256": "16f1lz2c6pzyjwmnqxxzl3sf635kzvzggmk2gl7mqifz4v31wjbq",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-json-rpc",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"json_rpc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/narxn874mr56chm56iya8zdmnadvg61d-nimcrypto-71bca15",
|
||||
"rev": "71bca15508e2c0548f32b42a69bcfb1ccd9ab9ff",
|
||||
"sha256": "0iizdwgxdrfa94572874dr5d3q2g9j6yk33xzywci7ig3w58rm82",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/cheatfate/nimcrypto",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"nimcrypto"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/mki47dpj9mi8wa7gwhp3n0q6z9lhn1mv-nim-bearssl-667b404",
|
||||
"rev": "667b40440a53a58e9f922e29e20818720c62d9ac",
|
||||
"sha256": "0a4mf9g7p7zdhlzzfl9iikmhkyl7w5kf2mrn0bv4w4n30sl98m4s",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-bearssl",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"bearssl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/cfs80kvd9s3np81i5bfr0pvhsv046vxm-nim-json-serialization-8a4ed98",
|
||||
"rev": "8a4ed98bbd0a9479df15af2fa31da38a586ea6d5",
|
||||
"sha256": "1r6acznzdyd3r5ixfhxbcqsrm6iqcyvrg5i93pzna1q4h9mgmf5f",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-json-serialization",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"json_serialization"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/vnxrmzlkma85rsf82abcr81ywrgr5dya-nim-chronicles-32ac867",
|
||||
"rev": "32ac8679680ea699f7dbc046e8e0131cac97d41a",
|
||||
"sha256": "0w3ya0rpy0rp997nnfakq0cshpk4vyva195mmgrw5c9zp4pwv2hm",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-chronicles",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"chronicles"
|
||||
]
|
||||
},
|
||||
{
|
||||
"method": "git",
|
||||
"path": "/nix/store/ngqb4fpv1yi4zn5x7sn3p3yvxmmbn2z1-nim-zlib-45b06fc",
|
||||
"rev": "45b06fca15ce0f09586067d950da30c10227865a",
|
||||
"sha256": "1gcvl59j7yj698sl4l35drq0cmvy2zsywgi7b0dv9ci3klss4cxb",
|
||||
"srcDir": "",
|
||||
"url": "https://github.com/status-im/nim-zlib",
|
||||
"subDir": "",
|
||||
"fetchSubmodules": true,
|
||||
"leaveDotGit": false,
|
||||
"packages": [
|
||||
"zlib"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
## nix begat oizys
|
||||
import std/[os, tables, sequtils, strformat,]
|
||||
import std/[os, tables, sequtils, strformat,strutils]
|
||||
|
||||
import cligen, bbansi
|
||||
import oizys/[context, github, nix, overlay, logging]
|
||||
|
@ -13,6 +13,17 @@ addHandler(
|
|||
)
|
||||
)
|
||||
|
||||
proc confirm(q: string): bool =
|
||||
stderr.write $(q & bb"[yellow] (Y/n) ")
|
||||
while true:
|
||||
let ans = readLine(stdin)
|
||||
case ans.strip().toLowerAscii():
|
||||
of "y","yes": return true
|
||||
of "n","no": return false
|
||||
else:
|
||||
stderr.write($bb("[red]Please answer Yes/no\nexpected one of [b]Y,yes,N,no "))
|
||||
stderr.write "\n"
|
||||
|
||||
overlay:
|
||||
proc pre(
|
||||
flake: string = "",
|
||||
|
@ -32,9 +43,20 @@ overlay:
|
|||
## output
|
||||
echo nixosConfigAttrs().join(" ")
|
||||
|
||||
proc update(yes: bool = false) =
|
||||
## *TBI* update and run nixos-rebuild
|
||||
fatal "not implemented"
|
||||
proc update(
|
||||
yes: bool = false,
|
||||
preview: bool = false
|
||||
) =
|
||||
## update and run nixos-rebuild
|
||||
let hosts = getHosts()
|
||||
if hosts.len > 1: fatalQuit "operation only supports one host"
|
||||
let run = getLastUpdateRun()
|
||||
echo fmt"run created at: {run.created_at}"
|
||||
echo "nvd diff:\n", getUpdateSummary(run.id, hosts[0])
|
||||
if preview: quit 0
|
||||
if yes or confirm("Proceed with system update?"):
|
||||
updateRepo()
|
||||
nixosRebuild("switch")
|
||||
|
||||
proc build(minimal: bool = false) =
|
||||
## nix build
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import std/[logging, os, strformat, strutils]
|
||||
from std/nativesockets import getHostname
|
||||
|
||||
import bbansi
|
||||
import ./logging
|
||||
|
||||
type
|
||||
OizysContext* = object
|
||||
flake, host: string
|
||||
flake: string
|
||||
hosts: seq[string]
|
||||
debug: bool
|
||||
ci: bool
|
||||
|
@ -37,15 +37,16 @@ proc updateContext*(
|
|||
debug: bool,
|
||||
resetCache: bool
|
||||
) =
|
||||
oc.debug = debug
|
||||
oc.resetCache = resetCache
|
||||
if host.len > 0:
|
||||
oc.hosts = host
|
||||
oc.debug = debug
|
||||
oc.resetCache = resetCache
|
||||
if flake != "":
|
||||
oc.flake =
|
||||
if flake.startsWith("github") or flake.startsWith("git+"): flake
|
||||
else: checkPath(flake.normalizedPath().absolutePath())
|
||||
debug oc
|
||||
|
||||
debug bb(fmt"""[b]flake[/]: {oc.flake}, [b]hosts[/]: {oc.hosts.join(" ")}""")
|
||||
|
||||
proc getHosts*(): seq[string] = return oc.hosts
|
||||
proc getFlake*(): string = return oc.flake
|
||||
|
|
|
@ -23,7 +23,7 @@ type
|
|||
|
||||
proc runCmdCapt*(
|
||||
cmd: string,
|
||||
capture: set[CaptureGrp],
|
||||
capture: set[CaptureGrp] = {CaptStdout},
|
||||
): tuple[stdout, stderr: string, exitCode: int] =
|
||||
debug fmt"running cmd: {cmd}"
|
||||
let args = cmd.splitWhitespace()
|
||||
|
|
|
@ -1,21 +1,43 @@
|
|||
import std/[httpclient,logging, os, strformat, strutils, json]
|
||||
import ./logging
|
||||
import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles]
|
||||
import jsony, bbansi, zippy/ziparchives
|
||||
import ./[logging, exec, context]
|
||||
|
||||
# localPassC is used by zippy but the additional
|
||||
# module mangling on nixos somehow breaks localPassC
|
||||
when defined(amd64) and (defined(gcc) or defined(clang)):
|
||||
{.passC: "-msse4.1 -mpclmul".}
|
||||
|
||||
template withTmpDir(body: untyped): untyped =
|
||||
let tmpDir {.inject.} = createTempDir("oizys","")
|
||||
body
|
||||
removeDir(tmpDir)
|
||||
|
||||
var ghToken = getEnv("GITHUB_TOKEN")
|
||||
|
||||
proc checkToken() {.inline.} =
|
||||
if ghToken == "": fatalQuit "GITHUB_TOKEN not set"
|
||||
|
||||
#[curl -L \
|
||||
-X POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "Authorization: Bearer <YOUR-TOKEN>" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches \
|
||||
-d '{"ref":"topic-branch","inputs":{"name":"Mona the Octocat","home":"San Francisco, CA"}}'
|
||||
]#
|
||||
proc ghClient(
|
||||
maxRedirects = 5
|
||||
): HttpClient =
|
||||
checkToken()
|
||||
result = newHttpClient(maxRedirects = maxRedirects)
|
||||
result.headers = newHttpHeaders({
|
||||
"Accept" : "application/vnd.github+json",
|
||||
"Authorization" : fmt"Bearer {ghToken}",
|
||||
"X-GitHub-Api-Version": "2022-11-28",
|
||||
})
|
||||
|
||||
|
||||
proc getGhApi(url: string): Response =
|
||||
let client = ghClient()
|
||||
try:
|
||||
result = client.get(url)
|
||||
except:
|
||||
error fmt"github api request failed: {url}"
|
||||
error fmt"response: {result.body}"
|
||||
quit QuitFailure
|
||||
|
||||
proc postGhApi(url: string, body: JsonNode) =
|
||||
checkToken()
|
||||
let client = newHttpClient()
|
||||
|
@ -43,4 +65,129 @@ proc createDispatch*(workflowFileName: string, `ref`: string) =
|
|||
}
|
||||
)
|
||||
|
||||
type
|
||||
GhArtifact = object
|
||||
id: int
|
||||
name: string
|
||||
url: string
|
||||
archive_download_url*: string
|
||||
|
||||
GhWorkflowRun = object
|
||||
id*: int
|
||||
node_id: string
|
||||
run_number: int
|
||||
event: string
|
||||
status: string
|
||||
conclusion: string
|
||||
html_url: string
|
||||
workflow_id: int
|
||||
created_at*: string # use datetime?
|
||||
updated_at: string # use datetime?
|
||||
|
||||
ListGhArtifactResponse = object
|
||||
total_count: int
|
||||
artifacts: seq[GhArtifact]
|
||||
|
||||
ListGhWorkflowResponse = object
|
||||
total_count: int
|
||||
workflow_runs: seq[GhWorkflowRun]
|
||||
|
||||
|
||||
proc listUpdateRuns(): seq[GhWorkflowRun] =
|
||||
## get update.yml runs
|
||||
## endpoint https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/runs
|
||||
debug "listing update workflows"
|
||||
let response = getGhApi("https://api.github.com/repos/daylinmorgan/oizys/actions/workflows/update.yml/runs")
|
||||
fromJson(response.body, ListGhWorkflowResponse).workflow_runs
|
||||
|
||||
proc getLastUpdateRun*(): GhWorkflowRun =
|
||||
let runs = listUpdateRuns()
|
||||
let run = runs[0]
|
||||
if run.conclusion == "failure":
|
||||
fatalQuit bb(fmt("Most recent run was not successful\n[b]runID[/]: {run.id}\n[b]conclusion[/]: {run.conclusion}"))
|
||||
if run.status in ["in_progress", "queued"]:
|
||||
fatalQuit bb(fmt("Most recent run is not finished\nview workflow run at: {run.html_url}"))
|
||||
result = run
|
||||
|
||||
|
||||
proc getArtifacts(runId: int): seq[GhArtifact] =
|
||||
## get workflow artifacts
|
||||
## https://api.github.com/repos/OWNER/REPO/actions/runs/RUN_ID/artifacts
|
||||
let response = getGhApi(fmt"https://api.github.com/repos/daylinmorgan/oizys/actions/runs/{runId}/artifacts")
|
||||
fromJson(response.body, ListGhArtifactResponse).artifacts
|
||||
|
||||
proc getUpdateSummaryArtifact(runId: int, host: string): GhArtifact =
|
||||
let name = fmt"{host}-summary"
|
||||
let artifacts = getArtifacts(runId)
|
||||
for artifact in artifacts:
|
||||
if artifact.name == name:
|
||||
return artifact
|
||||
fatalQuit fmt"failed to find summary for run id: {runID}"
|
||||
|
||||
proc getUpdateSummaryUrl(runID: int, host: string): string =
|
||||
## https://api.github.com/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID/ARCHIVE_FORMAT
|
||||
let artifact = getUpdateSummaryArtifact(runID, host)
|
||||
# httpclient was forwarding the Authorization headers,
|
||||
# which confused Azure where the archive lives...
|
||||
var response: Response
|
||||
try:
|
||||
let client = ghClient(maxRedirects = 0)
|
||||
response = client.get(artifact.archive_download_url)
|
||||
except:
|
||||
errorQuit fmt("fetching summary failed:\n\n{response.headers}\n\n{response.body}")
|
||||
|
||||
if "location" notin response.headers.table:
|
||||
errorQuit fmt("fetching summary failed:\n\n{response.headers}\n\n{response.body}")
|
||||
|
||||
let location = response.headers.table.getOrDefault("location", @[])
|
||||
if location.len == 0: errorQuit fmt("location header missing url?")
|
||||
return location[0]
|
||||
|
||||
proc fetchUpdateSummaryFromUrl(url: string): string =
|
||||
withTmpDir:
|
||||
let client = newHttpClient()
|
||||
client.downloadFile(url, tmpDir / "summary.zip")
|
||||
let reader = openZipArchive(tmpDir / "summary.zip")
|
||||
try:
|
||||
result = reader.extractFile("summary.md")
|
||||
finally:
|
||||
reader.close()
|
||||
|
||||
proc getUpdateSummary*(runId: int, host: string): string =
|
||||
let url = getUpdateSummaryUrl(runId, host)
|
||||
result = fetchUpdateSummaryFromUrl(url)
|
||||
|
||||
type
|
||||
GitRepo = object
|
||||
path: string
|
||||
|
||||
proc git(r: GitRepo, rest: varargs[string]): string =
|
||||
result = "git"
|
||||
result.addArgs ["-C", r.path]
|
||||
result.addArgs rest
|
||||
|
||||
proc checkGit(code: int) =
|
||||
if code != 0: fatalQuit "git had a non-zero exit status"
|
||||
|
||||
proc fetch(r: GitRepo) =
|
||||
let code = runCmd r.git("fetch", "origin")
|
||||
checkGit code
|
||||
|
||||
proc status(r: GitRepo) =
|
||||
let (output, _, code) = runCmdCapt(r.git("status", "--porcelain"))
|
||||
checkGit code
|
||||
if output.len > 0:
|
||||
info "unstaged commits, cowardly exiting..."
|
||||
quit QuitFailure
|
||||
|
||||
proc rebase(r: GitRepo, `ref`: string) =
|
||||
r.status()
|
||||
let code = runCmd r.git("rebase", `ref`)
|
||||
checkGit code
|
||||
|
||||
proc updateRepo*() =
|
||||
let repo = GitRepo(path: getFlake())
|
||||
fetch repo
|
||||
rebase repo, "origin/flake-lock"
|
||||
|
||||
|
||||
|
|
|
@ -20,3 +20,4 @@ gitea
|
|||
lock
|
||||
code
|
||||
comma-with-db
|
||||
nix-index-with-db
|
||||
|
|
|
@ -94,6 +94,7 @@ proc trunc(s: string, limit: int): string =
|
|||
|
||||
proc display(msg: string, drvs: seq[Derivation]) =
|
||||
echo fmt"{msg}: [bold cyan]{drvs.len()}[/]".bb
|
||||
if drvs.len > 0:
|
||||
let maxLen = min(max drvs.mapIt(it.name.len), 40)
|
||||
for drv in drvs:
|
||||
echo " ", drv.name.trunc(maxLen).alignLeft(maxLen), " ", drv.hash.bb("faint")
|
||||
|
@ -130,7 +131,7 @@ proc evaluateDerivations(drvs: seq[string]): Table[string, NixDerivation] =
|
|||
fromJson(output, Table[string,NixDerivation])
|
||||
|
||||
|
||||
# TODO: replace asserts in this proc
|
||||
# TODO: replace asserts in this proc, would be easier with results type
|
||||
proc findSystemPaths(drvs: Table[string, NixDerivation]): seq[string] =
|
||||
let hosts = getHosts()
|
||||
let systemDrvs = collect(
|
||||
|
@ -148,7 +149,8 @@ proc findSystemPaths(drvs: Table[string, NixDerivation]): seq[string] =
|
|||
|
||||
func isIgnored(drv: string): bool =
|
||||
const ignoredPackages = (slurp "ignored.txt").splitLines()
|
||||
drv.split("-", 1)[1].replace(".drv","") in ignoredPackages
|
||||
let name = drv.split("-", 1)[1].replace(".drv","")
|
||||
name in ignoredPackages
|
||||
|
||||
proc systemPathDrvsToBuild(): seq[string] =
|
||||
let toBuild = toBuildNixosConfiguration()
|
||||
|
@ -157,11 +159,12 @@ proc systemPathDrvsToBuild(): seq[string] =
|
|||
var inputDrvs: seq[string]
|
||||
for p in systemPaths:
|
||||
inputDrvs &= drvs[p].inputDrvs.keys().toSeq()
|
||||
result = collect(
|
||||
for drv in inputDrvs:
|
||||
if (drv in toBuild) and (not drv.isIgnored()):
|
||||
drv & "^*"
|
||||
)
|
||||
result = inputDrvs.filterIt(it in toBuild)
|
||||
let nToBuild = result.len
|
||||
result = result.filterIt(not it.isIgnored)
|
||||
let nIgnored = result.len - nToBuild
|
||||
debug fmt"ignored {nIgnored} derivations"
|
||||
result = result.mapIt(it & "^*")
|
||||
|
||||
func splitDrv(drv: string): tuple[name, hash:string] =
|
||||
let s = drv.split("-", 1)
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
# oizys-nim todo's
|
||||
|
||||
- [x] nix commands including dry runs
|
||||
- [ ] gh api commands
|
||||
- [x] ci <- start with the easier one
|
||||
- [ ] update
|
||||
|
||||
<!-- generated with <3 by daylinmorgan/todo -->
|
||||
|
|
Loading…
Reference in a new issue