Refactor packages
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
12
hosts/common/configs/system/nix-update/default.nix
Normal file
12
hosts/common/configs/system/nix-update/default.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
nix-update = prev.nix-update.overrideAttrs (oldAttrs: {
|
||||
patches = oldAttrs.patches or [ ] ++ [ ./source-attribute.patch ];
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [ nix-update ];
|
||||
}
|
127
hosts/common/configs/system/nix-update/source-attribute.patch
Normal file
127
hosts/common/configs/system/nix-update/source-attribute.patch
Normal file
@@ -0,0 +1,127 @@
|
||||
diff --git a/nix_update/__init__.py b/nix_update/__init__.py
|
||||
index 89bbe45..93f9322 100644
|
||||
--- a/nix_update/__init__.py
|
||||
+++ b/nix_update/__init__.py
|
||||
@@ -124,6 +124,12 @@ def parse_args(args: list[str]) -> Options:
|
||||
default=[],
|
||||
)
|
||||
|
||||
+ parser.add_argument(
|
||||
+ "--src-attr",
|
||||
+ help="Src attribute",
|
||||
+ default="src",
|
||||
+ )
|
||||
+
|
||||
a = parser.parse_args(args)
|
||||
extra_flags = ["--extra-experimental-features", "flakes nix-command"]
|
||||
if a.system:
|
||||
@@ -146,6 +152,7 @@ def parse_args(args: list[str]) -> Options:
|
||||
version=a.version,
|
||||
version_preference=VersionPreference.from_str(a.version),
|
||||
attribute=a.attribute,
|
||||
+ source_attribute=a.src_attr,
|
||||
test=a.test,
|
||||
version_regex=a.version_regex,
|
||||
review=a.review,
|
||||
diff --git a/nix_update/eval.py b/nix_update/eval.py
|
||||
index 1767056..f85ea69 100644
|
||||
--- a/nix_update/eval.py
|
||||
+++ b/nix_update/eval.py
|
||||
@@ -105,12 +105,19 @@ class Package:
|
||||
def eval_expression(
|
||||
escaped_import_path: str,
|
||||
attr: str,
|
||||
+ source_attr: str,
|
||||
flake: bool,
|
||||
system: str | None,
|
||||
override_filename: str | None,
|
||||
) -> str:
|
||||
system = f'"{system}"' if system else "builtins.currentSystem"
|
||||
|
||||
+ source_attrs = source_attr.rpartition(".")
|
||||
+ source_attr_last = source_attrs[-1] or source_attr
|
||||
+ source_attr_all_but_last = (
|
||||
+ f".{source_attrs[0]}" if source_attr_last != source_attr else ""
|
||||
+ )
|
||||
+
|
||||
if flake:
|
||||
sanitize_position = (
|
||||
f"""
|
||||
@@ -164,8 +171,8 @@ let
|
||||
raw_version_position
|
||||
else if pkg ? isPhpExtension then
|
||||
raw_version_position
|
||||
- else if (builtins.unsafeGetAttrPos "src" pkg) != null then
|
||||
- sanitizePosition (builtins.unsafeGetAttrPos "src" pkg)
|
||||
+ else if (builtins.unsafeGetAttrPos "{source_attr_last}" pkg) != null then
|
||||
+ sanitizePosition (builtins.unsafeGetAttrPos "{source_attr_last}" pkg{source_attr_all_but_last})
|
||||
else
|
||||
sanitizePosition (positionFromMeta pkg);
|
||||
in {{
|
||||
@@ -174,11 +181,11 @@ in {{
|
||||
inherit raw_version_position;
|
||||
filename = position.file;
|
||||
line = position.line;
|
||||
- urls = pkg.src.urls or null;
|
||||
- url = pkg.src.url or null;
|
||||
- rev = pkg.src.rev or null;
|
||||
- tag = pkg.src.tag or null;
|
||||
- hash = pkg.src.outputHash or null;
|
||||
+ urls = pkg.{source_attr}.urls or null;
|
||||
+ url = pkg.{source_attr}.url or null;
|
||||
+ rev = pkg.{source_attr}.rev or null;
|
||||
+ tag = pkg.{source_attr}.tag or null;
|
||||
+ hash = pkg.{source_attr}.outputHash or null;
|
||||
go_modules = pkg.goModules.outputHash or null;
|
||||
go_modules_old = pkg.go-modules.outputHash or null;
|
||||
cargo_deps = pkg.cargoDeps.outputHash or null;
|
||||
@@ -205,7 +212,7 @@ in {{
|
||||
mix_deps = pkg.mixFodDeps.outputHash or null;
|
||||
tests = builtins.attrNames (pkg.passthru.tests or {{}});
|
||||
has_update_script = {has_update_script};
|
||||
- src_homepage = pkg.src.meta.homepage or null;
|
||||
+ src_homepage = pkg.{source_attr}.meta.homepage or null;
|
||||
changelog = pkg.meta.changelog or null;
|
||||
maintainers = pkg.meta.maintainers or null;
|
||||
}}"""
|
||||
@@ -215,6 +222,7 @@ def eval_attr(opts: Options) -> Package:
|
||||
expr = eval_expression(
|
||||
opts.escaped_import_path,
|
||||
opts.escaped_attribute,
|
||||
+ opts.source_attribute,
|
||||
opts.flake,
|
||||
opts.system,
|
||||
opts.override_filename,
|
||||
diff --git a/nix_update/options.py b/nix_update/options.py
|
||||
index 2d07b77..ab5c305 100644
|
||||
--- a/nix_update/options.py
|
||||
+++ b/nix_update/options.py
|
||||
@@ -8,6 +8,7 @@ from .version.version import VersionPreference
|
||||
@dataclass
|
||||
class Options:
|
||||
attribute: str
|
||||
+ source_attribute: str = "src"
|
||||
flake: bool = False
|
||||
version: str = "stable"
|
||||
version_preference: VersionPreference = VersionPreference.STABLE
|
||||
@@ -33,4 +34,7 @@ class Options:
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
self.escaped_attribute = ".".join(map(json.dumps, self.attribute.split(".")))
|
||||
+ self.escaped_source_attribute = ".".join(
|
||||
+ map(json.dumps, self.source_attribute.split("."))
|
||||
+ )
|
||||
self.escaped_import_path = json.dumps(self.import_path)
|
||||
diff --git a/nix_update/update.py b/nix_update/update.py
|
||||
index 82b7bc5..464bf3d 100644
|
||||
--- a/nix_update/update.py
|
||||
+++ b/nix_update/update.py
|
||||
@@ -155,7 +155,7 @@ def git_prefetch(x: tuple[str, tuple[str, str]]) -> tuple[str, str]:
|
||||
|
||||
|
||||
def update_src_hash(opts: Options, filename: str, current_hash: str) -> None:
|
||||
- target_hash = nix_prefetch(opts, "src")
|
||||
+ target_hash = nix_prefetch(opts, opts.source_attribute)
|
||||
replace_hash(filename, current_hash, target_hash)
|
||||
|
||||
|
@@ -14,10 +14,13 @@
|
||||
];
|
||||
};
|
||||
|
||||
registry.self.flake = inputs.self;
|
||||
channel.enable = false;
|
||||
|
||||
gc.automatic = true;
|
||||
optimise.automatic = true;
|
||||
|
||||
registry.self.flake = inputs.self;
|
||||
|
||||
extraOptions = ''
|
||||
!include ${config.sops.secrets."nix/accessTokens/github".path}
|
||||
'';
|
||||
|
@@ -9,7 +9,12 @@
|
||||
|
||||
environment = {
|
||||
persistence."/persist"."/etc/ssh/ssh_host_ed25519_key" = { };
|
||||
systemPackages = with pkgs; [ sops ];
|
||||
|
||||
systemPackages = with pkgs; [
|
||||
sops
|
||||
age
|
||||
ssh-to-age
|
||||
];
|
||||
};
|
||||
|
||||
sops.age = {
|
||||
|
@@ -7,8 +7,12 @@
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
hmConfig = config.home-manager.users.${user};
|
||||
in
|
||||
{
|
||||
home-manager.users.${user} = {
|
||||
imports = [ inputs.ags.homeManagerModules.default ];
|
||||
@@ -19,12 +23,15 @@
|
||||
systemd.enable = true;
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
inputs.ags.packages.${pkgs.system}.hyprland
|
||||
inputs.ags.packages.${pkgs.system}.tray
|
||||
inputs.ags.packages.${system}.hyprland
|
||||
inputs.ags.packages.${system}.tray
|
||||
sassc
|
||||
hyprland
|
||||
nixos-icons
|
||||
(pkgs.callPackage ../cliphist/rofi.nix { })
|
||||
(import ../cliphist/rofi.nix {
|
||||
rofi = hmConfig.programs.rofi.finalPackage;
|
||||
inherit lib pkgs;
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
|
@@ -43,12 +43,13 @@ in
|
||||
finalPackage = mkOption {
|
||||
type = package;
|
||||
description = "The clipbook rofi package.";
|
||||
default = pkgs.callPackage ./rofi.nix {
|
||||
default = import ./rofi.nix {
|
||||
rofi = config.programs.rofi.finalPackage;
|
||||
bookmarks = builtins.mapAttrs (_: bookmark: {
|
||||
type = if bookmark.source != null then "file" else "text";
|
||||
content = if bookmark.source != null then bookmark.source else bookmark.text;
|
||||
}) cfg.bookmarks;
|
||||
inherit lib pkgs;
|
||||
};
|
||||
readOnly = true;
|
||||
};
|
||||
|
@@ -70,7 +70,10 @@ in
|
||||
wayland.windowManager.hyprland.settings.bind =
|
||||
let
|
||||
cliphist-rofi = lib.meta.getExe (
|
||||
pkgs.callPackage ./rofi.nix { rofi = hmConfig.programs.rofi.finalPackage; }
|
||||
import ./rofi.nix {
|
||||
rofi = hmConfig.programs.rofi.finalPackage;
|
||||
inherit pkgs lib;
|
||||
}
|
||||
);
|
||||
cliphist = lib.meta.getExe pkgs.cliphist;
|
||||
in
|
||||
|
@@ -2,8 +2,15 @@
|
||||
user ? throw "user argument is required",
|
||||
home ? throw "home argument is required",
|
||||
}:
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
selfPkgs = inputs.self.packages.${system};
|
||||
hmConfig = config.home-manager.users.${user};
|
||||
in
|
||||
{
|
||||
@@ -23,71 +30,60 @@ in
|
||||
"/cache"."${home}/.cache/darktable" = { };
|
||||
};
|
||||
|
||||
home-manager.users.${user} =
|
||||
let
|
||||
lua-scripts = pkgs.fetchFromGitHub {
|
||||
owner = "darktable-org";
|
||||
repo = "lua-scripts";
|
||||
rev = "daa0877b4c25b91e4b71afc1ef8ffcba6018f7b2";
|
||||
hash = "sha256-NNGAq1zgKqWLhKBPgm7kFZq4xwvescxnCAwovSF9r4k=";
|
||||
};
|
||||
|
||||
hald-clut = pkgs.fetchFromGitHub {
|
||||
owner = "cedeber";
|
||||
repo = "hald-clut";
|
||||
rev = "3b3180f82d4dcea1e6e8c5648473539a910d7f49";
|
||||
hash = "sha256-R8vyYmcsfk49QsSV3v0QblXcO6U0oIfDyxbHPLwSMdo=";
|
||||
};
|
||||
in
|
||||
{
|
||||
home = {
|
||||
packages = with pkgs; [
|
||||
home-manager.users.${user} = {
|
||||
home = {
|
||||
packages =
|
||||
with pkgs;
|
||||
with selfPkgs;
|
||||
[
|
||||
darktable
|
||||
exiftool
|
||||
(pkgs.callPackage ./publish { })
|
||||
darktable-ghost-cms-publish
|
||||
];
|
||||
|
||||
sessionVariables = {
|
||||
GHOST_URL = "https://photos.karaolidis.com";
|
||||
GHOST_ADMIN_API_KEY_PATH = hmConfig.sops.secrets."jupiter/photos.karaolidis.com/admin".path;
|
||||
};
|
||||
sessionVariables = {
|
||||
GHOST_URL = "https://photos.karaolidis.com";
|
||||
GHOST_ADMIN_API_KEY_PATH = hmConfig.sops.secrets."jupiter/photos.karaolidis.com/admin".path;
|
||||
};
|
||||
|
||||
xdg.configFile = {
|
||||
"darktable/darktablerc".source = (pkgs.formats.keyValue { }).generate "darktablerc" {
|
||||
"compress_xmp_tags" = "never";
|
||||
"database/create_snapshot" = "once a day";
|
||||
"rating_one_double_tap" = true;
|
||||
"run_crawler_on_start" = true;
|
||||
"ui_last/theme" = "darktable-elegant-darker";
|
||||
"ui_last/grouping" = true;
|
||||
"plugins/darkroom/lut3d/def_path" = "${home}/.config/darktable/luts";
|
||||
"opencl" = false;
|
||||
"plugins/lighttable/overlays/1/0" = 0;
|
||||
"plugins/lighttable/overlays/1/1" = 3;
|
||||
"plugins/lighttable/overlays/1/2" = 3;
|
||||
"plugins/darkroom/modulegroups/last_preset" = "modules: all";
|
||||
"session/base_directory_pattern" = "${home}/Pictures/Darktable";
|
||||
"session/filename_pattern" =
|
||||
"$(EXIF.YEAR)-$(EXIF.MONTH)-$(EXIF.DAY)_$(EXIF.HOUR)-$(EXIF.MINUTE)-$(EXIF.SECOND)_$(CONFLICT_PADDING).$(FILE_EXTENSION)";
|
||||
"session/sub_directory_pattern" = "";
|
||||
"setup_import_directory" = true;
|
||||
"lua/script_manager/check_update" = false;
|
||||
};
|
||||
|
||||
"darktable/luarc".text = ''
|
||||
require "tools/script_manager"
|
||||
require "tools/publish"
|
||||
'';
|
||||
|
||||
"darktable/lua/lib".source = "${lua-scripts}/lib";
|
||||
"darktable/lua/tools/script_manager.lua".source = "${lua-scripts}/tools/script_manager.lua";
|
||||
"darktable/lua/tools/publish.lua".source = ./publish/publish.lua;
|
||||
|
||||
"darktable/luts".source = "${hald-clut}/HaldCLUT";
|
||||
};
|
||||
|
||||
sops.secrets."jupiter/photos.karaolidis.com/admin".sopsFile =
|
||||
../../../../../../secrets/personal/secrets.yaml;
|
||||
};
|
||||
|
||||
xdg.configFile = {
|
||||
"darktable/darktablerc".source = (pkgs.formats.keyValue { }).generate "darktablerc" {
|
||||
"compress_xmp_tags" = "never";
|
||||
"database/create_snapshot" = "once a day";
|
||||
"rating_one_double_tap" = true;
|
||||
"run_crawler_on_start" = true;
|
||||
"ui_last/theme" = "darktable-elegant-darker";
|
||||
"ui_last/grouping" = true;
|
||||
"plugins/darkroom/lut3d/def_path" = "${home}/.config/darktable/luts";
|
||||
"opencl" = false;
|
||||
"plugins/lighttable/overlays/1/0" = 0;
|
||||
"plugins/lighttable/overlays/1/1" = 3;
|
||||
"plugins/lighttable/overlays/1/2" = 3;
|
||||
"plugins/darkroom/modulegroups/last_preset" = "modules: all";
|
||||
"session/base_directory_pattern" = "${home}/Pictures/Darktable";
|
||||
"session/filename_pattern" =
|
||||
"$(EXIF.YEAR)-$(EXIF.MONTH)-$(EXIF.DAY)_$(EXIF.HOUR)-$(EXIF.MINUTE)-$(EXIF.SECOND)_$(CONFLICT_PADDING).$(FILE_EXTENSION)";
|
||||
"session/sub_directory_pattern" = "";
|
||||
"setup_import_directory" = true;
|
||||
"lua/script_manager/check_update" = false;
|
||||
};
|
||||
|
||||
"darktable/luarc".text = ''
|
||||
require "tools/script_manager"
|
||||
require "tools/publish"
|
||||
'';
|
||||
|
||||
"darktable/lua/lib".source = "${selfPkgs.darktable-lua-scripts}/lib";
|
||||
"darktable/lua/tools/script_manager.lua".source =
|
||||
"${selfPkgs.darktable-lua-scripts}/tools/script_manager.lua";
|
||||
"darktable/lua/tools/publish.lua".source =
|
||||
"${selfPkgs.darktable-ghost-cms-publish}/lib/darktable-ghost-cms-publish/publish.lua";
|
||||
|
||||
"darktable/luts".source = selfPkgs.darktable-hald-clut;
|
||||
};
|
||||
|
||||
sops.secrets."jupiter/photos.karaolidis.com/admin".sopsFile =
|
||||
../../../../../../secrets/personal/secrets.yaml;
|
||||
};
|
||||
}
|
||||
|
@@ -1,2 +0,0 @@
|
||||
node_modules/
|
||||
build/
|
Binary file not shown.
@@ -1,29 +0,0 @@
|
||||
{ pkgs, lib, ... }:
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "darktable-publish";
|
||||
version = "1.0.0";
|
||||
src = ./.;
|
||||
|
||||
npmSrc = pkgs.buildNpmPackage ({
|
||||
inherit src pname version;
|
||||
npmDepsHash = "sha256-vBJIIuryC/zRvp9oKBVuCDTycPOpzgsLebU55CiIb7I=";
|
||||
dontNpmBuild = true;
|
||||
installPhase = ''
|
||||
cp -r . $out
|
||||
'';
|
||||
});
|
||||
|
||||
# FIXME: https://github.com/NixOS/nixpkgs/issues/255890
|
||||
wrapper = pkgs.writeShellApplication {
|
||||
name = pname;
|
||||
runtimeInputs = with pkgs; [ bun ];
|
||||
text = ''
|
||||
bun ${npmSrc}/src/index.ts "$@"
|
||||
'';
|
||||
};
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp ${lib.meta.getExe wrapper} $out/bin/
|
||||
'';
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
import globals from "globals";
|
||||
import pluginJs from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
/** @type {import('eslint').Linter.Config[]} */
|
||||
export default [
|
||||
{ files: ["**/*.{js,mjs,cjs,ts}"] },
|
||||
{ languageOptions: { globals: globals.browser } },
|
||||
pluginJs.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
];
|
File diff suppressed because it is too large
Load Diff
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "publish",
|
||||
"module": "src/index.ts",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.17.0",
|
||||
"@types/bun": "latest",
|
||||
"@types/jsonwebtoken": "^9.0.7",
|
||||
"eslint": "^9.17.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"globals": "^15.14.0",
|
||||
"prettier": "^3.4.2",
|
||||
"typescript-eslint": "^8.18.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": "^12.1.0",
|
||||
"exiftool-vendored": "^29.0.0",
|
||||
"jsonwebtoken": "^9.0.2"
|
||||
}
|
||||
}
|
@@ -1,133 +0,0 @@
|
||||
local dt = require "darktable"
|
||||
local df = require "lib/dtutils.file"
|
||||
local os = require "os"
|
||||
|
||||
-- Some fucking bullshit happening right here.
|
||||
function os.capture(command, raw)
|
||||
local f = assert(io.popen(command, 'r'))
|
||||
local s = assert(f:read('*a'))
|
||||
f:close()
|
||||
if raw then return s end
|
||||
s = string.gsub(s, '^%s+', '')
|
||||
s = string.gsub(s, '%s+$', '')
|
||||
s = string.gsub(s, '[\n\r]+', ' ')
|
||||
return s
|
||||
end
|
||||
|
||||
local publish_title = dt.new_widget("entry") {
|
||||
placeholder = "Post Title",
|
||||
tooltip = "enter title for the post"
|
||||
}
|
||||
|
||||
local publish_slug = dt.new_widget("entry") {
|
||||
placeholder = "post-slug",
|
||||
tooltip = "enter slug for the post (URL-friendly)"
|
||||
}
|
||||
|
||||
local publish_keywords = dt.new_widget("entry") {
|
||||
placeholder = "keywords (space-separated)",
|
||||
tooltip = "enter keywords (tags) for the post"
|
||||
}
|
||||
|
||||
local strip_gps_checkbox = dt.new_widget("check_button") {
|
||||
label = "Strip GPS data",
|
||||
value = false,
|
||||
tooltip = "remove GPS metadata from files before uploading"
|
||||
}
|
||||
|
||||
local widget = dt.new_widget("box") {
|
||||
orientation = "vertical",
|
||||
publish_title,
|
||||
publish_slug,
|
||||
publish_keywords,
|
||||
strip_gps_checkbox
|
||||
}
|
||||
|
||||
local function initialize(_, _, images, _, extra_data)
|
||||
extra_data.exported_files = {}
|
||||
extra_data.cleanup_files = {}
|
||||
|
||||
if publish_title.text == "" then
|
||||
extra_data.title = df.get_basename(images[1].filename)
|
||||
else
|
||||
extra_data.title = publish_title.text
|
||||
end
|
||||
|
||||
if publish_slug.text == "" then
|
||||
extra_data.slug = df.get_basename(images[1].filename)
|
||||
else
|
||||
extra_data.slug = publish_slug.text
|
||||
end
|
||||
|
||||
extra_data.keywords = publish_keywords.text
|
||||
extra_data.strip_gps = strip_gps_checkbox.value
|
||||
|
||||
return images
|
||||
end
|
||||
|
||||
local function store(_, image, _, filename, _, _, _, extra_data)
|
||||
if extra_data.strip_gps then
|
||||
local command = string.format("exiftool -gps:all= -overwrite_original '%s'", filename)
|
||||
os.execute(command)
|
||||
end
|
||||
|
||||
if image.is_raw then
|
||||
local original_path = image.path .. "/" .. image.filename
|
||||
local raw_filename = original_path
|
||||
|
||||
if extra_data.strip_gps then
|
||||
local tmpfile = os.tmpname()
|
||||
local command = string.format("exiftool -gps:all= -o '%s' '%s'", tmpfile, original_path)
|
||||
os.execute(command)
|
||||
table.insert(extra_data.cleanup_files, tmpfile)
|
||||
raw_filename = tmpfile
|
||||
end
|
||||
|
||||
table.insert(extra_data.exported_files, filename .. ":" .. raw_filename)
|
||||
else
|
||||
table.insert(extra_data.exported_files, filename)
|
||||
end
|
||||
end
|
||||
|
||||
local function finalize(_, _, extra_data)
|
||||
local files_arg = table.concat(extra_data.exported_files, " ")
|
||||
|
||||
local command = string.format(
|
||||
"darktable-publish --title '%s' --slug '%s' %s",
|
||||
extra_data.title, extra_data.slug, files_arg
|
||||
)
|
||||
if extra_data.keywords ~= "" then
|
||||
command = command .. string.format(" --keywords %s", extra_data.keywords)
|
||||
end
|
||||
|
||||
-- Ignore that I use an external tool (written in JavaScript god forbid)
|
||||
-- I am _not_ doing JSON generation and web requests in Lua
|
||||
local result = os.capture(command)
|
||||
|
||||
if result and result:match("^http") then
|
||||
dt.print("Post published: " .. result)
|
||||
else
|
||||
dt.print("Failed to publish post.")
|
||||
end
|
||||
|
||||
local command = string.format("xdg-open %s", result)
|
||||
os.execute(command)
|
||||
|
||||
for _, tmpfile in ipairs(extra_data.cleanup_files) do
|
||||
os.remove(tmpfile)
|
||||
end
|
||||
end
|
||||
|
||||
local function supported(_, _)
|
||||
return true
|
||||
end
|
||||
|
||||
dt.register_storage(
|
||||
"ghost_publish",
|
||||
"publish to Ghost CMS",
|
||||
store,
|
||||
finalize,
|
||||
supported,
|
||||
initialize,
|
||||
widget
|
||||
)
|
@@ -1,110 +0,0 @@
|
||||
import { sign } from "jsonwebtoken";
|
||||
import { file } from "bun";
|
||||
|
||||
const getAdminApiKey = async () => {
|
||||
const keyPath = process.env.GHOST_ADMIN_API_KEY_PATH;
|
||||
if (!keyPath) {
|
||||
throw new Error(
|
||||
"Environment variable GHOST_ADMIN_API_KEY_PATH is not set.",
|
||||
);
|
||||
}
|
||||
|
||||
const keyFile = file(keyPath);
|
||||
if (!(await keyFile.exists())) {
|
||||
throw new Error(`Key file not found at path: ${keyPath}`);
|
||||
}
|
||||
|
||||
return await keyFile.text();
|
||||
};
|
||||
|
||||
const getEndpoint = () => {
|
||||
const endpoint = process.env.GHOST_URL;
|
||||
if (!endpoint) {
|
||||
throw new Error("Environment variable GHOST_URL is not set.");
|
||||
}
|
||||
|
||||
return endpoint;
|
||||
};
|
||||
|
||||
const createJwt = (key: string) => {
|
||||
const [id, secret] = key.split(":");
|
||||
if (!id || !secret) {
|
||||
throw new Error("Invalid API key format. Expected format: {id}:{secret}");
|
||||
}
|
||||
|
||||
return sign({}, Buffer.from(secret, "hex"), {
|
||||
keyid: id,
|
||||
algorithm: "HS256",
|
||||
expiresIn: "5m",
|
||||
audience: `/admin/`,
|
||||
});
|
||||
};
|
||||
|
||||
const upload = async (
|
||||
slug: string,
|
||||
path: string,
|
||||
type: string | undefined,
|
||||
): Promise<any> => {
|
||||
const endpoint = getEndpoint();
|
||||
const fullEndpoint = `${endpoint}${slug}`;
|
||||
|
||||
const key = await getAdminApiKey();
|
||||
const token = createJwt(key);
|
||||
|
||||
const f = Bun.file(path, { type });
|
||||
const formData = new FormData();
|
||||
formData.append("file", f);
|
||||
|
||||
const response = await fetch(fullEndpoint, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Ghost ${token}`,
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Failed to upload to ${fullEndpoint}: ${response.status} ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
export const uploadImage = async (imagePath: string): Promise<string> => {
|
||||
const slug = `/ghost/api/admin/images/upload`;
|
||||
return (await upload(slug, imagePath, "image/jpeg")).images[0].url;
|
||||
};
|
||||
|
||||
export const uploadFile = async (filePath: string): Promise<string> => {
|
||||
const slug = `/ghost/api/admin/files/upload`;
|
||||
return (await upload(slug, filePath, undefined)).files[0].url;
|
||||
};
|
||||
|
||||
export const uploadPost = async (post: any): Promise<string> => {
|
||||
const endpoint = getEndpoint();
|
||||
const fullEndpoint = `${endpoint}/ghost/api/admin/posts`;
|
||||
|
||||
const key = await getAdminApiKey();
|
||||
const token = createJwt(key);
|
||||
|
||||
const response = await fetch(fullEndpoint, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Ghost ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
posts: [post],
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Failed to upload to ${fullEndpoint}: ${response.status} ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
|
||||
return (await response.json()).posts[0].url;
|
||||
};
|
@@ -1,48 +0,0 @@
|
||||
import { exiftool } from "exiftool-vendored";
|
||||
import type { FileInfo } from "./files";
|
||||
|
||||
export interface ShootingConditions {
|
||||
make: string;
|
||||
model: string;
|
||||
lensMake: string;
|
||||
lensModel: string;
|
||||
focalLength: string;
|
||||
focalLength35: string;
|
||||
shutterSpeed: string;
|
||||
fStop: string;
|
||||
iso: string;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export const extractShootingConditions = async (
|
||||
fileInfo: FileInfo,
|
||||
): Promise<ShootingConditions> => {
|
||||
const path = fileInfo.rawPath ?? fileInfo.jpegPath;
|
||||
|
||||
try {
|
||||
const exifData = await exiftool.read(path);
|
||||
|
||||
return {
|
||||
make: exifData.Make ?? "Unknown",
|
||||
model: exifData.Model ?? "Unknown",
|
||||
lensMake: exifData.LensMake ?? "Unknown",
|
||||
lensModel: exifData.LensModel ?? "Unknown",
|
||||
focalLength: exifData.FocalLength ?? "Unknown",
|
||||
focalLength35: exifData.FocalLengthIn35mmFormat ?? "Unknown",
|
||||
shutterSpeed: exifData.ExposureTime ?? "Unknown",
|
||||
fStop: exifData.FNumber?.toString() ?? "Unknown",
|
||||
iso: exifData.ISO?.toString() ?? "Unknown",
|
||||
timestamp: new Date(
|
||||
(exifData.CreateDate?.toString() as string).replace(/\./g, ":"),
|
||||
).toISOString(),
|
||||
};
|
||||
} catch (error: any) {
|
||||
throw new Error(
|
||||
`Failed to extract EXIF data from ${path}: ${error.message}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const createImageCaption = (exif: ShootingConditions) => {
|
||||
return `${exif.make} ${exif.model}, ${exif.lensMake} ${exif.lensModel} @ ${exif.focalLength} (${exif.focalLength35}), ${exif.shutterSpeed} s, f/${exif.fStop}, ISO ${exif.iso}`;
|
||||
};
|
@@ -1,66 +0,0 @@
|
||||
import { basename, extname } from "path";
|
||||
|
||||
export interface FileInfo {
|
||||
jpegPath: string;
|
||||
jpegSize: number;
|
||||
rawPath?: string;
|
||||
rawSize?: number;
|
||||
}
|
||||
|
||||
export const getBasenameWithoutExtension = (path: string): string => {
|
||||
const base = basename(path);
|
||||
const extension = extname(path);
|
||||
return base.slice(0, -extension.length);
|
||||
};
|
||||
|
||||
export const getBasenameWithExtension = (path: string): string => {
|
||||
return basename(path);
|
||||
};
|
||||
|
||||
export const prepareFiles = async (files: string[]): Promise<FileInfo[]> => {
|
||||
if (files.length > 10) {
|
||||
throw new Error("Up to 10 files are allowed at a time.");
|
||||
}
|
||||
|
||||
const parsedFiles: FileInfo[] = [];
|
||||
|
||||
for (const pair of files) {
|
||||
const parts = pair.split(/(?<!\\):/);
|
||||
const jpegPath = parts[0].replace(/\\:/g, ":");
|
||||
const rawPath = parts[1]?.replace(/\\:/g, ":");
|
||||
|
||||
const jpegFile = Bun.file(jpegPath);
|
||||
if (!(await jpegFile.exists())) {
|
||||
throw new Error(`JPEG file not found: ${jpegPath}`);
|
||||
}
|
||||
|
||||
const jpegSize = jpegFile.size;
|
||||
|
||||
if (!rawPath) {
|
||||
parsedFiles.push({
|
||||
jpegPath,
|
||||
jpegSize,
|
||||
rawPath: undefined,
|
||||
rawSize: undefined,
|
||||
});
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const rawFile = Bun.file(rawPath);
|
||||
if (!(await rawFile.exists())) {
|
||||
throw new Error(`RAW file not found: ${rawPath}`);
|
||||
}
|
||||
|
||||
const rawSize = rawFile.size;
|
||||
|
||||
parsedFiles.push({
|
||||
jpegPath,
|
||||
jpegSize,
|
||||
rawPath: rawPath,
|
||||
rawSize: rawSize,
|
||||
});
|
||||
}
|
||||
|
||||
return parsedFiles;
|
||||
};
|
@@ -1,112 +0,0 @@
|
||||
import { Command } from "commander";
|
||||
import { createFileNode, createImageNode, createHeadingNode } from "./lexical";
|
||||
import { extractShootingConditions, createImageCaption } from "./exif";
|
||||
import { uploadFile, uploadImage, uploadPost } from "./api";
|
||||
import { getBasenameWithExtension, prepareFiles } from "./files";
|
||||
|
||||
new Command()
|
||||
.name("darktable-publish")
|
||||
.description("Publish files to GHOST CMS with optional metadata.")
|
||||
.option("-t, --title [string]", "Specify the title")
|
||||
.option("-s, --slug [string]", "Specify the slug")
|
||||
.option("-k, --keywords [string...]", "Specify blog post keywords (tags)")
|
||||
.argument("<files...>", "Files to process")
|
||||
.action(async (files, options) => {
|
||||
if (!options.title) {
|
||||
throw new Error("Please specify a title.");
|
||||
}
|
||||
|
||||
if (!options.slug) {
|
||||
throw new Error("Please specify a slug.");
|
||||
}
|
||||
|
||||
const parsedFiles = await prepareFiles(files);
|
||||
|
||||
const [
|
||||
shootingConditions,
|
||||
uploadedJpegImages,
|
||||
uploadedJpegFiles,
|
||||
uploadedRawFiles,
|
||||
] = await Promise.all([
|
||||
Promise.all(parsedFiles.map(extractShootingConditions)),
|
||||
Promise.all(parsedFiles.map((f) => uploadImage(f.jpegPath))),
|
||||
Promise.all(parsedFiles.map((f) => uploadFile(f.jpegPath))),
|
||||
Promise.all(
|
||||
parsedFiles.map((f) =>
|
||||
f.rawPath ? uploadFile(f.rawPath) : Promise.resolve(undefined),
|
||||
),
|
||||
),
|
||||
]);
|
||||
|
||||
const aggregatedFiles = parsedFiles.map((file, index) => ({
|
||||
...file,
|
||||
shootingConditions: shootingConditions[index],
|
||||
uploadedJpegImage: uploadedJpegImages[index],
|
||||
uploadedJpegFile: uploadedJpegFiles[index],
|
||||
uploadedRawFile: uploadedRawFiles[index],
|
||||
}));
|
||||
|
||||
const result: any = {
|
||||
root: {
|
||||
children: [],
|
||||
direction: "ltr",
|
||||
format: "",
|
||||
indent: 0,
|
||||
type: "root",
|
||||
version: 1,
|
||||
},
|
||||
};
|
||||
|
||||
if (aggregatedFiles.length > 1) {
|
||||
aggregatedFiles.slice(1).forEach((file) =>
|
||||
result.root.children.push(
|
||||
createImageNode({
|
||||
src: file.uploadedJpegImage,
|
||||
caption: createImageCaption(file.shootingConditions),
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
result.root.children.push(createHeadingNode("Downloads", "h2"));
|
||||
|
||||
aggregatedFiles.forEach((file) => {
|
||||
result.root.children.push(
|
||||
createFileNode({
|
||||
src: file.uploadedJpegFile,
|
||||
name: getBasenameWithExtension(file.jpegPath),
|
||||
size: file.jpegSize,
|
||||
}),
|
||||
);
|
||||
|
||||
if (file.uploadedRawFile && file.rawPath && file.rawSize) {
|
||||
result.root.children.push(
|
||||
createFileNode({
|
||||
src: file.uploadedRawFile,
|
||||
name: getBasenameWithExtension(file.rawPath),
|
||||
size: file.rawSize,
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const post = {
|
||||
title: options.title,
|
||||
slug: options.slug,
|
||||
lexical: JSON.stringify(result),
|
||||
feature_image: aggregatedFiles[0].uploadedJpegImage,
|
||||
feature_image_caption: createImageCaption(
|
||||
aggregatedFiles[0].shootingConditions,
|
||||
),
|
||||
status: "published",
|
||||
visibility: "public",
|
||||
tags: options.keywords,
|
||||
published_at: aggregatedFiles[0].shootingConditions.timestamp,
|
||||
};
|
||||
|
||||
const url = await uploadPost(post);
|
||||
console.log(url);
|
||||
|
||||
process.exit(0);
|
||||
})
|
||||
.parse();
|
@@ -1,50 +0,0 @@
|
||||
export const createTextNode = (text: string) => ({
|
||||
detail: 0,
|
||||
format: 0,
|
||||
mode: "normal",
|
||||
style: "",
|
||||
text,
|
||||
type: "extended-text",
|
||||
version: 1,
|
||||
});
|
||||
|
||||
export const createHeadingNode = (text: string, level: string) => ({
|
||||
children: [createTextNode(text)],
|
||||
direction: "ltr",
|
||||
format: "",
|
||||
indent: 0,
|
||||
type: "extended-heading",
|
||||
version: 1,
|
||||
tag: level,
|
||||
});
|
||||
|
||||
export interface ImageInput {
|
||||
src: string;
|
||||
caption: string;
|
||||
}
|
||||
|
||||
export const createImageNode = (image: ImageInput) => {
|
||||
return {
|
||||
type: "image",
|
||||
version: 1,
|
||||
cardWidth: "wide",
|
||||
...image,
|
||||
};
|
||||
};
|
||||
|
||||
export interface FileInput {
|
||||
src: string;
|
||||
name: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
export const createFileNode = (file: FileInput) => {
|
||||
return {
|
||||
type: "file",
|
||||
src: file.src,
|
||||
fileTitle: file.name,
|
||||
fileName: file.name,
|
||||
fileCaption: "",
|
||||
fileSize: file.size,
|
||||
};
|
||||
};
|
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// Enable latest features
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.better-word-count";
|
||||
version = "0.10.1";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "karaolidis";
|
||||
rev = "8ff00d7e9aed03d8cf38215b742a2a2251cc2ea2";
|
||||
# owner = "lukeleppan";
|
||||
repo = "better-word-count";
|
||||
# rev = version;
|
||||
hash = "sha256-wA0vycuUHr7icgAJ/d85j3bbwqlefXnSyRUXgCmqyOE=";
|
||||
};
|
||||
|
||||
patches = [ ./package-lock.patch ];
|
||||
makeCacheWritable = true;
|
||||
|
||||
npmDepsHash = "sha256-K+NGIKsSNzGHGcAofsl0WcNsTFt/y38zUdGUZL013xg=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./dist/main.js $out/main.js
|
||||
cp ./src/styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
diff --git a/package-lock.json b/package-lock.json
|
||||
index 3fa99a5..71302ec 100644
|
||||
--- a/package-lock.json
|
||||
+++ b/package-lock.json
|
||||
@@ -15,7 +15,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/commands": "^6.1.2",
|
||||
- "@codemirror/language": "https://github.com/lishid/cm-language",
|
||||
+ "@codemirror/language": "https://github.com/karaolidis/cm-language#package-lock",
|
||||
"@codemirror/search": "^6.2.2",
|
||||
"@codemirror/state": "^6.1.2",
|
||||
"@codemirror/view": "^6.4.0",
|
||||
@@ -49,7 +49,7 @@
|
||||
},
|
||||
"node_modules/@codemirror/language": {
|
||||
"version": "6.10.1",
|
||||
- "resolved": "git+ssh://git@github.com/lishid/cm-language.git#2644bfc27afda707a7e1f3aedaf3ca7120f63cd9",
|
||||
+ "resolved": "git+ssh://git@github.com/karaolidis/cm-language.git#d6238f0a9e17e20d604cee67a47d3a93b00dd41c",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
diff --git a/package.json b/package.json
|
||||
index 2537f1e..ba6bfff 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -24,7 +24,7 @@
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@codemirror/commands": "^6.1.2",
|
||||
- "@codemirror/language": "https://github.com/lishid/cm-language",
|
||||
+ "@codemirror/language": "https://github.com/karaolidis/cm-language#package-lock",
|
||||
"@codemirror/search": "^6.2.2",
|
||||
"@codemirror/state": "^6.1.2",
|
||||
"@codemirror/view": "^6.4.0",
|
@@ -1,30 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "obsidian.plugins.custom-sort";
|
||||
version = "3.1.2";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "SebastianMC";
|
||||
repo = "obsidian-custom-sort";
|
||||
rev = version;
|
||||
hash = "sha256-a6t0+mzzXQsgUwZ3m3UvF3N83ajGmxalsnD8beAVAr0=";
|
||||
};
|
||||
|
||||
offlineCache = pkgs.fetchYarnDeps {
|
||||
yarnLock = src + "/yarn.lock";
|
||||
hash = "sha256-J/+LJWaco2QRwZx8Ry3G5DiJB6J21iOn5GBeY5EY4+g=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nodejs
|
||||
yarnConfigHook
|
||||
yarnBuildHook
|
||||
npmHooks.npmInstallHook
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./dist/main.js $out/main.js
|
||||
'';
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.dataview";
|
||||
version = "0.5.67";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "blacksmithgu";
|
||||
repo = "obsidian-dataview";
|
||||
rev = version;
|
||||
hash = "sha256-AbK1J1a8bqkPCe9dqADAfR/q/j/kRGa8qouj9GJQErc=";
|
||||
};
|
||||
|
||||
patches = [ ./package-lock.patch ];
|
||||
makeCacheWritable = true;
|
||||
|
||||
npmDepsHash = "sha256-FsPLpWcS27VWrDm5G1ZT6zvfOfYmKNLHzmjiXEmpGKE=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./build/main.js $out/main.js
|
||||
cp ./styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,90 +0,0 @@
|
||||
diff --git a/package-lock.json b/package-lock.json
|
||||
index 0c1b0bd..df26135 100644
|
||||
--- a/package-lock.json
|
||||
+++ b/package-lock.json
|
||||
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "obsidian-dataview",
|
||||
- "version": "0.5.66",
|
||||
+ "version": "0.5.67",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "obsidian-dataview",
|
||||
- "version": "0.5.66",
|
||||
+ "version": "0.5.67",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
- "@codemirror/language": "https://github.com/lishid/cm-language",
|
||||
+ "@codemirror/language": "https://github.com/karaolidis/cm-language#package-lock",
|
||||
"@codemirror/state": "^6.0.1",
|
||||
"@codemirror/view": "^6.0.1",
|
||||
"emoji-regex": "^10.0.0",
|
||||
@@ -687,29 +687,28 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@codemirror/language": {
|
||||
- "version": "6.6.0",
|
||||
- "resolved": "git+ssh://git@github.com/lishid/cm-language.git#1aadcc247f20ccfda76424a9f853dbb4ee203fdc",
|
||||
- "license": "MIT",
|
||||
+ "version": "6.10.1",
|
||||
+ "resolved": "git+ssh://git@github.com/karaolidis/cm-language.git#d6238f0a9e17e20d604cee67a47d3a93b00dd41c",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
- "@codemirror/view": "^6.0.0",
|
||||
- "@lezer/common": "^1.0.0",
|
||||
+ "@codemirror/view": "^6.23.0",
|
||||
+ "@lezer/common": "^1.1.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0",
|
||||
"style-mod": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/state": {
|
||||
- "version": "6.2.1",
|
||||
- "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.2.1.tgz",
|
||||
- "integrity": "sha512-RupHSZ8+OjNT38zU9fKH2sv+Dnlr8Eb8sl4NOnnqz95mCFTZUaiRP8Xv5MeeaG0px2b8Bnfe7YGwCV3nsBhbuw=="
|
||||
+ "version": "6.4.1",
|
||||
+ "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.4.1.tgz",
|
||||
+ "integrity": "sha512-QkEyUiLhsJoZkbumGZlswmAhA7CBU02Wrz7zvH4SrcifbsqwlXShVXg65f3v/ts57W3dqyamEriMhij1Z3Zz4A=="
|
||||
},
|
||||
"node_modules/@codemirror/view": {
|
||||
- "version": "6.19.0",
|
||||
- "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.19.0.tgz",
|
||||
- "integrity": "sha512-XqNIfW/3GaaF+T7Q1jBcRLCPm1NbrR2DBxrXacSt1FG+rNsdsNn3/azAfgpUoJ7yy4xgd8xTPa3AlL+y0lMizQ==",
|
||||
+ "version": "6.28.4",
|
||||
+ "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.28.4.tgz",
|
||||
+ "integrity": "sha512-QScv95fiviSQ/CaVGflxAvvvDy/9wi0RFyDl4LkHHWiMr/UPebyuTspmYSeN5Nx6eujcPYwsQzA6ZIZucKZVHQ==",
|
||||
"dependencies": {
|
||||
- "@codemirror/state": "^6.1.4",
|
||||
+ "@codemirror/state": "^6.4.0",
|
||||
"style-mod": "^4.1.0",
|
||||
"w3c-keyname": "^2.2.4"
|
||||
}
|
||||
@@ -1133,9 +1132,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/common": {
|
||||
- "version": "1.0.4",
|
||||
- "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.4.tgz",
|
||||
- "integrity": "sha512-lZHlk8p67x4aIDtJl6UQrXSOP6oi7dQR3W/geFVrENdA1JDaAJWldnVqVjPMJupbTKbzDfFcePfKttqVidS/dg=="
|
||||
+ "version": "1.2.1",
|
||||
+ "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.2.1.tgz",
|
||||
+ "integrity": "sha512-yemX0ZD2xS/73llMZIK6KplkjIjf2EvAHcinDi/TfJ9hS25G0388+ClHt6/3but0oOxinTcQHJLDXh6w1crzFQ=="
|
||||
},
|
||||
"node_modules/@lezer/highlight": {
|
||||
"version": "1.1.6",
|
||||
diff --git a/package.json b/package.json
|
||||
index db15b53..d3605a0 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -47,7 +47,7 @@
|
||||
"rollup-plugin-web-worker-loader": "^1.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
- "@codemirror/language": "https://github.com/lishid/cm-language",
|
||||
+ "@codemirror/language": "https://github.com/karaolidis/cm-language#package-lock",
|
||||
"@codemirror/state": "^6.0.1",
|
||||
"@codemirror/view": "^6.0.1",
|
||||
"emoji-regex": "^10.0.0",
|
@@ -1,47 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.excalidraw";
|
||||
version = "2.8.3";
|
||||
|
||||
pkg = pkgs.fetchFromGitHub {
|
||||
owner = "zsviczian";
|
||||
repo = "obsidian-excalidraw-plugin";
|
||||
rev = version;
|
||||
hash = "sha256-vfswTT+FzzcddUQSoy6xseE+PzsWtRx8RkYzqGn6wFQ=";
|
||||
};
|
||||
|
||||
mathjaxToSVG = pkgs.buildNpmPackage {
|
||||
pname = "obsidian.plugins.excalidraw.mathjaxToSVG";
|
||||
version = "1.0.0";
|
||||
src = "${pkg}/MathjaxToSVG";
|
||||
npmDepsHash = "sha256-AosKWlX08dpXNQ2YlrfR6jEInmU02Ztf26nmV19Jxok=";
|
||||
|
||||
configurePhase = ''
|
||||
mkdir dist
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./dist/index.js $out/index.js
|
||||
'';
|
||||
};
|
||||
|
||||
src = pkg;
|
||||
patches = [ ./package-lock.patch ];
|
||||
|
||||
npmDepsHash = "sha256-6Y22TD6BMljRGrL/qT54F7bFXcQbY1bQ5GuKEqAXIwY=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
configurePhase = ''
|
||||
mkdir dist
|
||||
mkdir -p ./MathjaxToSVG/dist
|
||||
cp ${mathjaxToSVG}/index.js ./MathjaxToSVG/dist/index.js
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./dist/manifest.json $out/manifest.json
|
||||
cp ./dist/main.js $out/main.js
|
||||
cp ./dist/styles.css $out/styles.css
|
||||
'';
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,24 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.folder-note";
|
||||
version = "0.7.3";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "karaolidis";
|
||||
rev = "2d14ccb5179beb48c3df87108170aeda067584ac";
|
||||
# owner = "xpgo";
|
||||
repo = "obsidian-folder-note-plugin";
|
||||
# rev = version;
|
||||
hash = "sha256-Ub0u+hMbkzxeUjzVmA61S0ClXR9E3KrYTqhrJBQj0Wg=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-4v6QwwooxsXy+mbiKriylpKa8NOK8pWZixezY+H6wxo=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
cp ./styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "obsidian.plugins.kanban";
|
||||
version = "2.0.51";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "mgmeyers";
|
||||
repo = "obsidian-kanban";
|
||||
rev = version;
|
||||
hash = "sha256-NahypggwPrub2KxRBAn54ZpEInP1V+6l/xmUKUt6myA=";
|
||||
};
|
||||
|
||||
offlineCache = pkgs.fetchYarnDeps {
|
||||
yarnLock = src + "/yarn.lock";
|
||||
hash = "sha256-eof2W9Ja4RlmjQ0SnaF/jadHX3GRkCRrMwZU2z0M/Jk=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nodejs
|
||||
yarnConfigHook
|
||||
yarnBuildHook
|
||||
npmHooks.npmInstallHook
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
cp ./styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "obsidian.plugins.languagetool";
|
||||
version = "0.3.7";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "karaolidis";
|
||||
rev = "a7bb62f767decbd55b14702c35e24954459e77ca";
|
||||
# owner = "Clemens-E";
|
||||
repo = "obsidian-languagetool-plugin";
|
||||
# rev = version;
|
||||
hash = "sha256-LeSK9ctdKW6P3AoOWHxHmGxIlOXDOVd1nhsWXdRSiZY=";
|
||||
};
|
||||
|
||||
patches = [ ./settings-notification.patch ];
|
||||
|
||||
offlineCache = pkgs.fetchYarnDeps {
|
||||
yarnLock = src + "/yarn.lock";
|
||||
hash = "sha256-749RGQmg9Mte7TR6k3qP6xcb8+rj/C60LYLbF8j8gNc=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nodejs
|
||||
yarnConfigHook
|
||||
yarnBuildHook
|
||||
npmHooks.npmInstallHook
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
cp ./styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
diff --git a/src/index.ts b/src/index.ts
|
||||
index 00cccfe..43e6107 100644
|
||||
--- a/src/index.ts
|
||||
+++ b/src/index.ts
|
||||
@@ -42,7 +42,6 @@ export default class LanguageToolPlugin extends Plugin {
|
||||
try {
|
||||
await this.saveSettings();
|
||||
await this.loadSettings();
|
||||
- new Notice('updated LanguageTool Settings, please confirm your server URL in the settings tab', 10000);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.linter";
|
||||
version = "1.28.0";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "platers";
|
||||
repo = "obsidian-linter";
|
||||
rev = version;
|
||||
hash = "sha256-pMcVowcV0k/OcG6cITRxt3HOA5QJDaery6upLPWSxpM=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-XgOgAJoRXhQIQNnubU0uL7e7SGJvRhWvPktMNZN5F5U=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
cp ./src/styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.map-view";
|
||||
version = "5.0.2";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "karaolidis";
|
||||
rev = "e1d2737f20e8667417b040b4dcad020aa6de84d3";
|
||||
# owner = "esm7";
|
||||
repo = "obsidian-map-view";
|
||||
# rev = version;
|
||||
hash = "sha256-Tmp8/li82BHVY3pLwi5l86NTXzfzrcRMZFMVNWiItXE=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-BsiFThkaZHQcayTuI5uvD5uD710eDVPgkANSj7Qd5S0=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./dist/manifest.json $out/manifest.json
|
||||
cp ./dist/main.js $out/main.js
|
||||
cp ./dist/styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.minimal-settings";
|
||||
version = "8.1.1";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "karaolidis";
|
||||
rev = "5a69fb195726cc61ae3ca9b14fb1a78862397529";
|
||||
# owner = "kepano";
|
||||
repo = "obsidian-minimal-settings";
|
||||
# rev = version;
|
||||
hash = "sha256-FPZMdOcwkCnCN0v3IgiFnhBLrnuqU7DR7XE+qheYdZE=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-E8CPsBmuV51GC3N5qxz8haa249vMfm3TZyZVsyPwfkg=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
cp ./styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.outliner";
|
||||
version = "4.8.1";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "vslinko";
|
||||
repo = "obsidian-outliner";
|
||||
rev = version;
|
||||
hash = "sha256-LfkK1c3khA75UZQMJStvV2bccHTz4eMqtEIC8jPFKBM=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-EVSunBtuOo93Zhq95u80j/MArRZaAyKdcwUz61qHXiQ=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
cp ./styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.read-it-later";
|
||||
version = "0.11.4";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "DominikPieper";
|
||||
repo = "obsidian-ReadItLater";
|
||||
rev = version;
|
||||
hash = "sha256-Favp5YhRTYhMGsLuPWiFwmU3zA3vwZkkdXABBVy7NNs=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-PUQc3qM/pjJkkO3zpCmga8eO8XaNxyeZAw+0GNPg5Ro=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
'';
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "obsidian.plugins.style-settings";
|
||||
version = "1.0.9";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "karaolidis";
|
||||
rev = "21f29b7aea728d9040ed209cddb7d9f05c68be1f";
|
||||
# owner = "mgmeyers";
|
||||
repo = "obsidian-style-settings";
|
||||
# rev = version;
|
||||
hash = "sha256-6xyp5PE4mhKYP3Lc4vKUG/N3aqBhHGwsCuzfVkq1jwM=";
|
||||
};
|
||||
|
||||
offlineCache = pkgs.fetchYarnDeps {
|
||||
yarnLock = src + "/yarn.lock";
|
||||
hash = "sha256-tqX09XWI3ZL9bXVdjgsAEuvfCAjnyWj5uSWGFbNApds=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nodejs
|
||||
yarnConfigHook
|
||||
yarnBuildHook
|
||||
npmHooks.npmInstallHook
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
cp ./styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "obsidian.plugins.tasks";
|
||||
version = "7.15.0";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "obsidian-tasks-group";
|
||||
repo = "obsidian-tasks";
|
||||
rev = version;
|
||||
hash = "sha256-BF9ye4ocE6vZh+ChkmuLkQpNWtH425EX0EHQs+wbTZc=";
|
||||
};
|
||||
|
||||
offlineCache = pkgs.fetchYarnDeps {
|
||||
yarnLock = src + "/yarn.lock";
|
||||
hash = "sha256-Tf1K048Ox+hImIfrdBWQHsiDe+3FGUQLFBcf/Bbbo1U=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nodejs
|
||||
yarnConfigHook
|
||||
yarnBuildHook
|
||||
npmHooks.npmInstallHook
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
cp ./styles.css $out/styles.css
|
||||
'';
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.plugins.url-into-selection";
|
||||
version = "1.7.0";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "karaolidis";
|
||||
rev = "9f85d59be28797b7ef16c452fa3c4093f60b3bab";
|
||||
# owner = "denolehov";
|
||||
repo = "obsidian-url-into-selection";
|
||||
# rev = version;
|
||||
hash = "sha256-MQV8CMzCha0MUGLh4c1WuHVXRiCPEwtSgd3Xoj/81hA=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-tThyrhezHZ29JUzx5sy2SfoZIGYP0DOQBctxYB5O1P4=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./main.js $out/main.js
|
||||
'';
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildNpmPackage rec {
|
||||
pname = "obsidian.themes.minimal";
|
||||
version = "7.7.18";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "kepano";
|
||||
repo = "obsidian-minimal";
|
||||
rev = version;
|
||||
hash = "sha256-zOUOE8EQlnnOmEhkWQmT28eH2Yk7fgkNvbxjJzLXio8=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-PzsZv/On8ci6EkF3WE4aez3/jQu5AqyJxFUzJk+Pn0c=";
|
||||
npmPackFlags = [ "--ignore-scripts" ];
|
||||
|
||||
nativeBuildInputs = with pkgs; [ sass ];
|
||||
|
||||
buildPhase = ''
|
||||
npx grunt cssmin
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ./manifest.json $out/manifest.json
|
||||
cp ./theme.css $out/theme.css
|
||||
'';
|
||||
}
|
@@ -6,9 +6,12 @@
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
selfPkgs = inputs.self.packages.${system};
|
||||
hmConfig = config.home-manager.users.${user};
|
||||
in
|
||||
{
|
||||
@@ -73,7 +76,7 @@ in
|
||||
|
||||
communityPlugins = [
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/better-word-count { };
|
||||
pkg = selfPkgs.obsidian-plugin-better-word-count;
|
||||
options = {
|
||||
statusBar = [
|
||||
{
|
||||
@@ -99,7 +102,7 @@ in
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/custom-sort { };
|
||||
pkg = selfPkgs.obsidian-plugin-custom-sort;
|
||||
options = {
|
||||
suspended = false;
|
||||
statusBarEntryEnabled = false;
|
||||
@@ -110,7 +113,7 @@ in
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/dataview { };
|
||||
pkg = selfPkgs.obsidian-plugin-dataview;
|
||||
options = {
|
||||
enableDataviewJs = true;
|
||||
enableInlineDataviewJs = true;
|
||||
@@ -120,7 +123,7 @@ in
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/excalidraw { };
|
||||
pkg = selfPkgs.obsidian-plugin-excalidraw;
|
||||
options = {
|
||||
folder = "Inbox";
|
||||
templateFilePath = "Templates";
|
||||
@@ -143,14 +146,14 @@ in
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/folder-note { };
|
||||
pkg = selfPkgs.obsidian-plugin-folder-note;
|
||||
options = {
|
||||
folderNoteHide = false;
|
||||
folderNoteStrInit = "";
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/kanban { };
|
||||
pkg = selfPkgs.obsidian-plugin-kanban;
|
||||
options = {
|
||||
move-tags = true;
|
||||
move-dates = true;
|
||||
@@ -164,7 +167,7 @@ in
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/languagetool { };
|
||||
pkg = selfPkgs.obsidian-plugin-languagetool;
|
||||
options = {
|
||||
shouldAutoCheck = true;
|
||||
pickyMode = true;
|
||||
@@ -173,7 +176,7 @@ in
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/linter { };
|
||||
pkg = selfPkgs.obsidian-plugin-linter;
|
||||
options = {
|
||||
lintOnSave = true;
|
||||
displayChanged = false;
|
||||
@@ -313,7 +316,7 @@ in
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/map-view { };
|
||||
pkg = selfPkgs.obsidian-plugin-map-view;
|
||||
options = {
|
||||
"markerIconRules" = [
|
||||
{
|
||||
@@ -399,20 +402,20 @@ in
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/minimal-settings { };
|
||||
pkg = selfPkgs.obsidian-plugin-minimal-settings;
|
||||
options = {
|
||||
editorFont = "var(--font-monospace)";
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/outliner { };
|
||||
pkg = selfPkgs.obsidian-plugin-outliner;
|
||||
options = {
|
||||
styleLists = false;
|
||||
stickCursor = "never";
|
||||
};
|
||||
}
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/read-it-later { };
|
||||
pkg = selfPkgs.obsidian-plugin-read-it-later;
|
||||
options = {
|
||||
inboxDir = "Inbox";
|
||||
assetsDir = "Inbox/assets";
|
||||
@@ -498,9 +501,9 @@ in
|
||||
textSnippetNote = "%content%";
|
||||
};
|
||||
}
|
||||
(pkgs.callPackage ./config/plugins/style-settings { })
|
||||
(selfPkgs.obsidian-plugin-style-settings)
|
||||
{
|
||||
pkg = pkgs.callPackage ./config/plugins/tasks { };
|
||||
pkg = selfPkgs.obsidian-plugin-tasks;
|
||||
options = {
|
||||
globalQuery = "short mode";
|
||||
globalFilter = "#todo";
|
||||
@@ -646,12 +649,12 @@ in
|
||||
};
|
||||
};
|
||||
}
|
||||
(pkgs.callPackage ./config/plugins/url-into-selection { })
|
||||
(selfPkgs.obsidian-plugin-url-into-selection)
|
||||
];
|
||||
|
||||
cssSnippets = [ ./config/snippets/file-explorer-separators.css ];
|
||||
|
||||
themes = [ (pkgs.callPackage ./config/themes/minimal { }) ];
|
||||
themes = [ selfPkgs.obsidian-theme-minimal ];
|
||||
|
||||
hotkeys = {
|
||||
"command-palette:open" = [ { key = "F1"; } ];
|
||||
|
@@ -6,7 +6,7 @@
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
@@ -28,7 +28,7 @@ in
|
||||
|
||||
programs.spicetify =
|
||||
let
|
||||
spicePkgs = inputs.spicetify-nix.legacyPackages.${pkgs.system};
|
||||
spicePkgs = inputs.spicetify-nix.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
|
@@ -21,75 +21,76 @@ in
|
||||
|
||||
programs.vscode = {
|
||||
enable = true;
|
||||
|
||||
mutableExtensionsDir = false;
|
||||
|
||||
extensions = with pkgs.vscode-extensions; [
|
||||
mkhl.direnv
|
||||
mhutchie.git-graph
|
||||
ms-vsliveshare.vsliveshare
|
||||
naumovs.color-highlight
|
||||
];
|
||||
profiles.default = {
|
||||
extensions = with pkgs.vscode-extensions; [
|
||||
mkhl.direnv
|
||||
mhutchie.git-graph
|
||||
ms-vsliveshare.vsliveshare
|
||||
naumovs.color-highlight
|
||||
];
|
||||
|
||||
userSettings = {
|
||||
"diffEditor.ignoreTrimWhitespace" = false;
|
||||
"editor.accessibilitySupport" = "off";
|
||||
"editor.cursorBlinking" = "phase";
|
||||
"editor.cursorSmoothCaretAnimation" = "on";
|
||||
"editor.fontFamily" = builtins.concatStringsSep ", " hmConfig.theme.font.monospace.names;
|
||||
"editor.fontLigatures" = true;
|
||||
"editor.fontSize" = hmConfig.theme.font.size;
|
||||
"editor.formatOnPaste" = true;
|
||||
"editor.formatOnSave" = true;
|
||||
"editor.formatOnType" = true;
|
||||
"editor.indentSize" = "tabSize";
|
||||
"editor.inlineSuggest.enabled" = true;
|
||||
"editor.largeFileOptimizations" = false;
|
||||
"editor.linkedEditing" = true;
|
||||
"editor.renderFinalNewline" = "on";
|
||||
"editor.smoothScrolling" = true;
|
||||
"editor.stickyScroll.enabled" = true;
|
||||
"editor.suggestSelection" = "first";
|
||||
"editor.tabSize" = 2;
|
||||
"editor.unicodeHighlight.includeComments" = true;
|
||||
"editor.unicodeHighlight.nonBasicASCII" = true;
|
||||
"explorer.confirmDelete" = false;
|
||||
"explorer.confirmDragAndDrop" = false;
|
||||
"explorer.confirmPasteNative" = false;
|
||||
"extensions.autoCheckUpdates" = false;
|
||||
"extensions.autoUpdate" = false;
|
||||
"extensions.ignoreRecommendations" = true;
|
||||
"files.autoSave" = "afterDelay";
|
||||
"files.eol" = "\n";
|
||||
"files.insertFinalNewline" = true;
|
||||
"files.trimFinalNewlines" = true;
|
||||
"files.trimTrailingWhitespace" = true;
|
||||
"git.allowForcePush" = true;
|
||||
"git.alwaysSignOff" = true;
|
||||
"git.autofetch" = "all";
|
||||
"git.closeDiffOnOperation" = true;
|
||||
"git.confirmForcePush" = false;
|
||||
"git.confirmSync" = false;
|
||||
"git.enableCommitSigning" = true;
|
||||
"git.enableSmartCommit" = true;
|
||||
"git.ignoreRebaseWarning" = true;
|
||||
"git.openRepositoryInParentFolders" = "always";
|
||||
"git.path" = lib.meta.getExe pkgs.git;
|
||||
"mergeEditor.diffAlgorithm" = "advanced";
|
||||
"security.workspace.trust.enabled" = false;
|
||||
"telemetry.telemetryLevel" = "off";
|
||||
"terminal.external.linuxExec" = "kitty";
|
||||
"terminal.integrated.confirmOnExit" = "hasChildProcesses";
|
||||
"terminal.integrated.copyOnSelection" = true;
|
||||
"terminal.integrated.fontFamily" =
|
||||
builtins.concatStringsSep ", " hmConfig.theme.font.monospace.names;
|
||||
"terminal.integrated.fontSize" = hmConfig.theme.font.size;
|
||||
"update.mode" = "none";
|
||||
"window.autoDetectColorScheme" = true;
|
||||
"window.autoDetectHighContrast" = false;
|
||||
"window.menuBarVisibility" = "toggle";
|
||||
"workbench.editor.historyBasedLanguageDetection" = true;
|
||||
"workbench.list.smoothScrolling" = true;
|
||||
userSettings = {
|
||||
"diffEditor.ignoreTrimWhitespace" = false;
|
||||
"editor.accessibilitySupport" = "off";
|
||||
"editor.cursorBlinking" = "phase";
|
||||
"editor.cursorSmoothCaretAnimation" = "on";
|
||||
"editor.fontFamily" = builtins.concatStringsSep ", " hmConfig.theme.font.monospace.names;
|
||||
"editor.fontLigatures" = true;
|
||||
"editor.fontSize" = hmConfig.theme.font.size;
|
||||
"editor.formatOnPaste" = true;
|
||||
"editor.formatOnSave" = true;
|
||||
"editor.formatOnType" = true;
|
||||
"editor.indentSize" = "tabSize";
|
||||
"editor.inlineSuggest.enabled" = true;
|
||||
"editor.largeFileOptimizations" = false;
|
||||
"editor.linkedEditing" = true;
|
||||
"editor.renderFinalNewline" = "on";
|
||||
"editor.smoothScrolling" = true;
|
||||
"editor.stickyScroll.enabled" = true;
|
||||
"editor.suggestSelection" = "first";
|
||||
"editor.tabSize" = 2;
|
||||
"editor.unicodeHighlight.includeComments" = true;
|
||||
"editor.unicodeHighlight.nonBasicASCII" = true;
|
||||
"explorer.confirmDelete" = false;
|
||||
"explorer.confirmDragAndDrop" = false;
|
||||
"explorer.confirmPasteNative" = false;
|
||||
"extensions.autoCheckUpdates" = false;
|
||||
"extensions.autoUpdate" = false;
|
||||
"extensions.ignoreRecommendations" = true;
|
||||
"files.autoSave" = "afterDelay";
|
||||
"files.eol" = "\n";
|
||||
"files.insertFinalNewline" = true;
|
||||
"files.trimFinalNewlines" = true;
|
||||
"files.trimTrailingWhitespace" = true;
|
||||
"git.allowForcePush" = true;
|
||||
"git.alwaysSignOff" = true;
|
||||
"git.autofetch" = "all";
|
||||
"git.closeDiffOnOperation" = true;
|
||||
"git.confirmForcePush" = false;
|
||||
"git.confirmSync" = false;
|
||||
"git.enableCommitSigning" = true;
|
||||
"git.enableSmartCommit" = true;
|
||||
"git.ignoreRebaseWarning" = true;
|
||||
"git.openRepositoryInParentFolders" = "always";
|
||||
"git.path" = lib.meta.getExe pkgs.git;
|
||||
"mergeEditor.diffAlgorithm" = "advanced";
|
||||
"security.workspace.trust.enabled" = false;
|
||||
"telemetry.telemetryLevel" = "off";
|
||||
"terminal.external.linuxExec" = "kitty";
|
||||
"terminal.integrated.confirmOnExit" = "hasChildProcesses";
|
||||
"terminal.integrated.copyOnSelection" = true;
|
||||
"terminal.integrated.fontFamily" =
|
||||
builtins.concatStringsSep ", " hmConfig.theme.font.monospace.names;
|
||||
"terminal.integrated.fontSize" = hmConfig.theme.font.size;
|
||||
"update.mode" = "none";
|
||||
"window.autoDetectColorScheme" = true;
|
||||
"window.autoDetectHighContrast" = false;
|
||||
"window.menuBarVisibility" = "toggle";
|
||||
"workbench.editor.historyBasedLanguageDetection" = true;
|
||||
"workbench.list.smoothScrolling" = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.c.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [
|
||||
ms-vscode.cpptools
|
||||
ms-vscode.cmake-tools
|
||||
];
|
||||
|
@@ -5,5 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.docker.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [ ms-azuretools.vscode-docker ];
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [
|
||||
ms-azuretools.vscode-docker
|
||||
];
|
||||
}
|
||||
|
@@ -5,5 +5,5 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.go.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [ golang.go ];
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [ golang.go ];
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.java.enable {
|
||||
programs.vscode = {
|
||||
programs.vscode.profiles.default = {
|
||||
extensions =
|
||||
with pkgs;
|
||||
with vscode-extensions;
|
||||
|
@@ -5,5 +5,5 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.jinja.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [ wholroyd.jinja ];
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [ wholroyd.jinja ];
|
||||
}
|
||||
|
@@ -5,5 +5,5 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.lua.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [ sumneko.lua ];
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [ sumneko.lua ];
|
||||
}
|
||||
|
@@ -5,5 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.markdown.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [ yzhang.markdown-all-in-one ];
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [
|
||||
yzhang.markdown-all-in-one
|
||||
];
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.nix.enable {
|
||||
programs.vscode = {
|
||||
programs.vscode.profiles.default = {
|
||||
userSettings = {
|
||||
"nix.enableLanguageServer" = true;
|
||||
"nix.serverPath" = lib.meta.getExe pkgs.nil;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.python.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [
|
||||
ms-python.python
|
||||
ms-python.vscode-pylance
|
||||
ms-python.debugpy
|
||||
|
@@ -5,7 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.rest.enable {
|
||||
programs.vscode = {
|
||||
programs.vscode.profiles.default = {
|
||||
extensions = with pkgs.vscode-extensions; [ humao.rest-client ];
|
||||
|
||||
userSettings = {
|
||||
|
@@ -5,5 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.python.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [ rust-lang.rust-analyzer ];
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [
|
||||
rust-lang.rust-analyzer
|
||||
];
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.sas.enable {
|
||||
programs.vscode = {
|
||||
programs.vscode.profiles.default = {
|
||||
extensions = with pkgs.vscode-extensions; [ sas.sas-lsp ];
|
||||
|
||||
userSettings = {
|
||||
|
@@ -5,5 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.sops.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [ signageos.signageos-vscode-sops ];
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [
|
||||
signageos.signageos-vscode-sops
|
||||
];
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.svelte.enable {
|
||||
programs.vscode = {
|
||||
programs.vscode.profiles.default = {
|
||||
userSettings = {
|
||||
"svelte.enable-ts-plugin" = true;
|
||||
};
|
||||
|
@@ -1,11 +1,6 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{ config, lib, ... }:
|
||||
lib.mkIf config.programs.vscode.languages.typescript.enable {
|
||||
programs.vscode.userSettings = {
|
||||
programs.vscode.profiles.default.userSettings = {
|
||||
"typescript.updateImportsOnFileMove.enabled" = "always";
|
||||
};
|
||||
}
|
||||
|
@@ -5,5 +5,5 @@
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.programs.vscode.languages.yaml.enable {
|
||||
programs.vscode.extensions = with pkgs.vscode-extensions; [ redhat.vscode-yaml ];
|
||||
programs.vscode.profiles.default.extensions = with pkgs.vscode-extensions; [ redhat.vscode-yaml ];
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ in
|
||||
];
|
||||
|
||||
config = {
|
||||
programs.vscode = {
|
||||
programs.vscode.profiles.default = {
|
||||
extensions =
|
||||
with pkgs.vscode-extensions;
|
||||
[ ]
|
||||
|
11
hosts/common/shells/default.nix
Normal file
11
hosts/common/shells/default.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
bun = import ./bun { inherit pkgs; };
|
||||
c = import ./c { inherit pkgs; };
|
||||
go = import ./go { inherit pkgs; };
|
||||
java = import ./java { inherit pkgs; };
|
||||
nix = import ./nix { inherit pkgs; };
|
||||
nodejs = import ./nodejs { inherit pkgs; };
|
||||
python = import ./python { inherit pkgs; };
|
||||
rust = import ./rust { inherit pkgs; };
|
||||
}
|
@@ -27,6 +27,7 @@
|
||||
../common/configs/system/nix-cleanup
|
||||
../common/configs/system/nix-install
|
||||
../common/configs/system/nix-ld
|
||||
../common/configs/system/nix-update
|
||||
../common/configs/system/nixpkgs
|
||||
../common/configs/system/ntp
|
||||
../common/configs/system/pipewire
|
||||
|
@@ -46,7 +46,7 @@
|
||||
};
|
||||
|
||||
programs = {
|
||||
vscode.userSettings."window.zoomLevel" = (1.25 - 1) / 0.2;
|
||||
vscode.profiles.default.userSettings."window.zoomLevel" = (1.25 - 1) / 0.2;
|
||||
|
||||
obs-studio.resolution = {
|
||||
base = {
|
||||
|
@@ -27,6 +27,7 @@
|
||||
../common/configs/system/nix-cleanup
|
||||
../common/configs/system/nix-install
|
||||
../common/configs/system/nix-ld
|
||||
../common/configs/system/nix-update
|
||||
../common/configs/system/nixpkgs
|
||||
../common/configs/system/ntp
|
||||
../common/configs/system/pipewire
|
||||
|
@@ -7,7 +7,7 @@
|
||||
wayland.windowManager.hyprland.settings.monitor = "eDP-1, 1920x1200@60, 0x0, 1";
|
||||
|
||||
programs = {
|
||||
vscode.userSettings."window.zoomLevel" = (1.25 - 1) / 0.2;
|
||||
vscode.profiles.default.userSettings."window.zoomLevel" = (1.25 - 1) / 0.2;
|
||||
|
||||
obs-studio.resolution = {
|
||||
base = {
|
||||
|
@@ -1,8 +0,0 @@
|
||||
{
|
||||
user ? throw "user argument is required",
|
||||
home ? throw "home argument is required",
|
||||
}:
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home-manager.users.${user}.home.packages = [ (pkgs.callPackage ./package.nix { }) ];
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildGoModule rec {
|
||||
pname = "jsonify";
|
||||
version = "0.1.6";
|
||||
|
||||
src = fetchGit {
|
||||
url = "git@github.com:sas-institute-rnd-internal/polaris-jsonify.git";
|
||||
ref = "main";
|
||||
rev = "7b8f8a0f0b3c1bbfb7f814c5a3dae5f696ca38e3";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-sJ3Jc7ZC+1s3m5nH6WtXsGVZfLEW7CZAcNtstUpc9M4=";
|
||||
|
||||
preBuild = ''
|
||||
rm -rf sage
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp "$GOPATH/bin/polaris-jsonify" $out/bin/jsonify
|
||||
'';
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
{
|
||||
user ? throw "user argument is required",
|
||||
home ? throw "home argument is required",
|
||||
}:
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home-manager.users.${user}.home.packages = [ (pkgs.callPackage ./package.nix { }) ];
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildGoModule rec {
|
||||
pname = "klog";
|
||||
version = "0.6.2";
|
||||
|
||||
src = fetchGit {
|
||||
url = "git@gitlab.sas.com:convoy/devops/klog.git";
|
||||
ref = "master";
|
||||
rev = "17629fe278dd23e12bd6f17ee9db0d2fde37bc6c";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-nYlJhGe1Jd3/ct0XpTdMqbgnnoYM0dqVVVfr9nVsu4o=";
|
||||
|
||||
patches = [ ./remove-version-flag.patch ];
|
||||
|
||||
preBuild = ''
|
||||
export GOPROXY="goproxy.unx.sas.com"
|
||||
export GONOSUMDB="*.sas.com,sassoftware.io"
|
||||
'';
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
diff --git a/main.go b/main.go
|
||||
index 6fee5d3..a8d45dd 100644
|
||||
--- a/main.go
|
||||
+++ b/main.go
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
- "runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -27,20 +26,8 @@ func main() {
|
||||
flag.StringVar(&f, "format", "term", "Log output format (one of json|pretty|yaml|line|file|term|logfmt|plain|message|template)")
|
||||
flag.StringVar(&ml, "l", "trace", "Minimum log level to output (in order, one of trace|debug|info|warn|error|fatal|panic|none|disabled)")
|
||||
flag.StringVar(&tz, "t", defaultTimeZone, "Timezone to use for formatting log timestamps - One of UTC, Local, or from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones")
|
||||
- var ver bool
|
||||
- flag.BoolVar(&ver, "version", false, "Show version information")
|
||||
flag.Parse()
|
||||
|
||||
- if ver {
|
||||
- fmt.Printf("Copyright © 2021, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.\n"+
|
||||
- "Command - %s\n"+
|
||||
- "Version - %s+%s\n"+
|
||||
- "Build Date - %s\n"+
|
||||
- "Compiler - %s %s/%s\n",
|
||||
- "klog", BuildVersion, BuildCommit, BuildDate, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||
- os.Exit(0)
|
||||
- }
|
||||
-
|
||||
lf, ok := log.Formatters[f]
|
||||
if !ok {
|
||||
fmt.Fprintf(os.Stderr, "invalid value for format: [%s] - must be one of json|pretty|yaml|line|file|term|logfmt|plain|message|template", f)
|
@@ -1,8 +0,0 @@
|
||||
{
|
||||
user ? throw "user argument is required",
|
||||
home ? throw "home argument is required",
|
||||
}:
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home-manager.users.${user}.home.packages = [ (pkgs.callPackage ./package.nix { }) ];
|
||||
}
|
@@ -1,364 +0,0 @@
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index 07ae204..28e5e8a 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -11,6 +11,8 @@
|
||||
*.pyo
|
||||
*.sa
|
||||
*.so
|
||||
+*.eggs
|
||||
+*.__pycache__/
|
||||
|
||||
# Logs and databases #
|
||||
######################
|
||||
@@ -43,4 +45,4 @@ Thumbs.db
|
||||
/bin/
|
||||
build
|
||||
docker
|
||||
-/**/.pytest_cache/
|
||||
\ No newline at end of file
|
||||
+/**/.pytest_cache/
|
||||
diff --git a/deployment_report/templates/__init__.py b/deployment_report/templates/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
diff --git a/ldap_validator/library/__init__.py b/ldap_validator/library/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
diff --git a/ldap_validator/library/utils/__init__.py b/ldap_validator/library/utils/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
diff --git a/pre_install_report/templates/__init__.py b/pre_install_report/templates/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
diff --git a/setup.cfg b/setup.cfg
|
||||
index 1c80cb2..4ffdef1 100644
|
||||
--- a/setup.cfg
|
||||
+++ b/setup.cfg
|
||||
@@ -2,7 +2,11 @@
|
||||
name = viya4-ark
|
||||
author = SAS Institute Inc.
|
||||
summary = The SAS Viya Administration Resource Kit (SAS Viya ARK) provides tools and utilities to help SAS customers prepare for and gather information about a SAS Viya platform deployment.
|
||||
-description-file = README.md
|
||||
-description-content-type = text/markdown
|
||||
-home-page = https://github.com/sassoftware/viya4-ark
|
||||
+description_file = README.md
|
||||
+description_content_type = text/markdown
|
||||
+home_page = https://github.com/sassoftware/viya4-ark
|
||||
license = Apache-2.0
|
||||
+
|
||||
+[options.entry_points]
|
||||
+console_scripts =
|
||||
+ viya4-ark = viya4_ark:main
|
||||
diff --git a/setup.py b/setup.py
|
||||
index d3dd4f5..05cbeb7 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -14,10 +14,14 @@
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
+packages = find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"])
|
||||
+
|
||||
setup(
|
||||
- setup_requires=["pbr"],
|
||||
- pbr=True,
|
||||
- licenses_files=["LICENSE"],
|
||||
- packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
|
||||
+ setup_requires=[],
|
||||
+ license_files=["LICENSE"],
|
||||
+ py_modules=["viya4_ark"],
|
||||
+ packages=packages,
|
||||
+ include_package_data=True,
|
||||
+ package_data={package: ["*"] for package in packages},
|
||||
python_requires=">=3.6",
|
||||
)
|
||||
diff --git a/viya-ark.py b/viya-ark.py
|
||||
deleted file mode 100644
|
||||
index 7626a89..0000000
|
||||
--- a/viya-ark.py
|
||||
+++ /dev/null
|
||||
@@ -1,139 +0,0 @@
|
||||
-####################################################################
|
||||
-# ### viya-ark.py ###
|
||||
-####################################################################
|
||||
-# ### Author: SAS Institute Inc. ###
|
||||
-####################################################################
|
||||
-# ###
|
||||
-# Copyright (c) 2020, SAS Institute Inc., Cary, NC, USA. ###
|
||||
-# All Rights Reserved. ###
|
||||
-# SPDX-License-Identifier: Apache-2.0 ###
|
||||
-# ###
|
||||
-####################################################################
|
||||
-
|
||||
-import importlib
|
||||
-import inspect
|
||||
-import os
|
||||
-import pkgutil
|
||||
-import sys
|
||||
-
|
||||
-from viya_ark_library.command import Command
|
||||
-
|
||||
-# command line options #
|
||||
-_HELP_SHORT_OPT_ = "h"
|
||||
-_HELP_LONG_OPT_ = "help"
|
||||
-
|
||||
-# return codes #
|
||||
-_SUCCESS_RC_ = 0
|
||||
-_BAD_OPT_RC_ = 1
|
||||
-
|
||||
-
|
||||
-################
|
||||
-# Main #
|
||||
-################
|
||||
-def main(argv: list):
|
||||
- """
|
||||
- The main executable method for the viya-ark launcher script.
|
||||
-
|
||||
- :param argv: The list of arguments passed at invocation.
|
||||
- """
|
||||
- try:
|
||||
- # get the requested command value #
|
||||
- command_name = argv[0]
|
||||
-
|
||||
- # print the usage and exit, if requested #
|
||||
- if command_name in (f"-{_HELP_SHORT_OPT_}", f"--{_HELP_LONG_OPT_}"):
|
||||
- usage(_SUCCESS_RC_)
|
||||
-
|
||||
- # convert any dashes in the given command to underscores to align with Pythonic package/module standards #
|
||||
- command_module_name = command_name.replace("-", "_")
|
||||
-
|
||||
- # attempt to import the requested command module #
|
||||
- imported_module = None
|
||||
- try:
|
||||
- imported_module = importlib.import_module(f"{command_module_name}.{command_module_name}")
|
||||
- except ModuleNotFoundError:
|
||||
- print()
|
||||
- print(f"ERROR: Command [{command_name}] not found.")
|
||||
- usage(_BAD_OPT_RC_)
|
||||
-
|
||||
- # find any attributes in the module that implement the Command class using reflection #
|
||||
- command = None
|
||||
- for attribute_name in dir(imported_module):
|
||||
- # get the current module attribute by name #
|
||||
- attribute = getattr(imported_module, attribute_name)
|
||||
-
|
||||
- # if the attribute is: #
|
||||
- # (1) a class -AND- #
|
||||
- # (2) a subclass of Command -AND- #
|
||||
- # (3) not abstract #
|
||||
- # then the attribute defines a command for the project. #
|
||||
- if inspect.isclass(attribute) and issubclass(attribute, Command) and not inspect.isabstract(attribute):
|
||||
- command = attribute
|
||||
- # the Command implementation was found, the loop can break #
|
||||
- break
|
||||
-
|
||||
- if command is not None:
|
||||
- # call the Command's run() method to delegate execution to the module, pass all relevant arguments #
|
||||
- command.run(argv[1:])
|
||||
- else:
|
||||
- # if a Command implementation wasn't found, print the usage message #
|
||||
- print()
|
||||
- print(f"ERROR: Command [{command_name}] not found.")
|
||||
- usage(_BAD_OPT_RC_)
|
||||
-
|
||||
- except IndexError:
|
||||
- # if the launcher script wasn't given enough args, print the usage #
|
||||
- print()
|
||||
- print("ERROR: A command must be provided.")
|
||||
- usage(_BAD_OPT_RC_)
|
||||
-
|
||||
-
|
||||
-#################
|
||||
-# Usage #
|
||||
-#################
|
||||
-def usage(exit_code: int):
|
||||
- """
|
||||
- Prints the usage statement for the viya-ark launcher script and exits with the provided exit_code.
|
||||
-
|
||||
- :param exit_code: The code to return upon exit.
|
||||
- """
|
||||
- commands = list()
|
||||
-
|
||||
- # walk through all packages parallel to this script #
|
||||
- paths = [os.path.realpath(os.path.dirname(__file__))]
|
||||
- for importer, name, is_package in pkgutil.walk_packages(path=paths):
|
||||
- # skip any objects that are packages (i.e. not modules) #
|
||||
- if not is_package:
|
||||
- # import the current module #
|
||||
- try:
|
||||
- importlib.import_module(name)
|
||||
- except ModuleNotFoundError as e:
|
||||
- # ignore any issues importing pytest, raise any other module import errors
|
||||
- if e.name != "pytest":
|
||||
- raise e
|
||||
-
|
||||
- for subclass in Command.__subclasses__():
|
||||
- # create a tuple of command details by calling the command_name() and command_desc() methods #
|
||||
- command_details = (subclass().command_name(), subclass().command_desc())
|
||||
- # add the command details to the list of discovered commands #
|
||||
- commands.append(command_details)
|
||||
-
|
||||
- # print the commands as well as the static help command to stdout #
|
||||
- print()
|
||||
- print(f"Usage: {os.path.basename(__file__)} <command> [options]")
|
||||
- print()
|
||||
- print("Commands:")
|
||||
- for command in commands:
|
||||
- print(" {:<30} {}".format(command[0], command[1]))
|
||||
- help_cmd_display = f"-{_HELP_SHORT_OPT_}, --{_HELP_LONG_OPT_}"
|
||||
- print(" {:<30} {}".format(help_cmd_display, "Display usage for viya-ark."))
|
||||
- print()
|
||||
-
|
||||
- sys.exit(exit_code)
|
||||
-
|
||||
-
|
||||
-##################
|
||||
-# __main__ #
|
||||
-##################
|
||||
-if __name__ == "__main__":
|
||||
- main(sys.argv[1:])
|
||||
diff --git a/viya4_ark.py b/viya4_ark.py
|
||||
new file mode 100644
|
||||
index 0000000..1af3b79
|
||||
--- /dev/null
|
||||
+++ b/viya4_ark.py
|
||||
@@ -0,0 +1,136 @@
|
||||
+####################################################################
|
||||
+# ### main.py ###
|
||||
+####################################################################
|
||||
+# ### Author: SAS Institute Inc. ###
|
||||
+####################################################################
|
||||
+# ###
|
||||
+# Copyright (c) 2020, SAS Institute Inc., Cary, NC, USA. ###
|
||||
+# All Rights Reserved. ###
|
||||
+# SPDX-License-Identifier: Apache-2.0 ###
|
||||
+# ###
|
||||
+####################################################################
|
||||
+
|
||||
+import importlib
|
||||
+import inspect
|
||||
+import os
|
||||
+import pkgutil
|
||||
+import sys
|
||||
+
|
||||
+from viya_ark_library.command import Command
|
||||
+
|
||||
+# command line options #
|
||||
+_HELP_SHORT_OPT_ = "h"
|
||||
+_HELP_LONG_OPT_ = "help"
|
||||
+
|
||||
+# return codes #
|
||||
+_SUCCESS_RC_ = 0
|
||||
+_BAD_OPT_RC_ = 1
|
||||
+
|
||||
+
|
||||
+################
|
||||
+# Main #
|
||||
+################
|
||||
+def main():
|
||||
+ """
|
||||
+ The main executable method for the viya-ark launcher script.
|
||||
+ """
|
||||
+ argv = sys.argv[1:]
|
||||
+
|
||||
+ if len(argv) == 0:
|
||||
+ print("ERROR: A command must be provided.")
|
||||
+ usage(_BAD_OPT_RC_)
|
||||
+
|
||||
+ command_name = argv[0]
|
||||
+
|
||||
+ # print the usage and exit, if requested #
|
||||
+ if command_name in (f"-{_HELP_SHORT_OPT_}", f"--{_HELP_LONG_OPT_}"):
|
||||
+ usage(_SUCCESS_RC_)
|
||||
+
|
||||
+ # convert any dashes in the given command to underscores to align with Pythonic package/module standards #
|
||||
+ command_module_name = command_name.replace("-", "_")
|
||||
+
|
||||
+ # attempt to import the requested command module #
|
||||
+ imported_module = None
|
||||
+ try:
|
||||
+ imported_module = importlib.import_module(f"{command_module_name}.{command_module_name}")
|
||||
+ except ModuleNotFoundError:
|
||||
+ print()
|
||||
+ print(f"ERROR: Command [{command_name}] not found.")
|
||||
+ usage(_BAD_OPT_RC_)
|
||||
+
|
||||
+ # find any attributes in the module that implement the Command class using reflection #
|
||||
+ command = None
|
||||
+ for attribute_name in dir(imported_module):
|
||||
+ # get the current module attribute by name #
|
||||
+ attribute = getattr(imported_module, attribute_name)
|
||||
+
|
||||
+ # if the attribute is: #
|
||||
+ # (1) a class -AND- #
|
||||
+ # (2) a subclass of Command -AND- #
|
||||
+ # (3) not abstract #
|
||||
+ # then the attribute defines a command for the project. #
|
||||
+ if inspect.isclass(attribute) and issubclass(attribute, Command) and not inspect.isabstract(attribute):
|
||||
+ command = attribute
|
||||
+ # the Command implementation was found, the loop can break #
|
||||
+ break
|
||||
+
|
||||
+ if command is not None:
|
||||
+ # call the Command's run() method to delegate execution to the module, pass all relevant arguments #
|
||||
+ command.run(argv[1:])
|
||||
+ else:
|
||||
+ # if a Command implementation wasn't found, print the usage message #
|
||||
+ print()
|
||||
+ print(f"ERROR: Command [{command_name}] not found.")
|
||||
+ usage(_BAD_OPT_RC_)
|
||||
+
|
||||
+
|
||||
+#################
|
||||
+# Usage #
|
||||
+#################
|
||||
+def usage(exit_code: int):
|
||||
+ """
|
||||
+ Prints the usage statement for the viya-ark launcher script and exits with the provided exit_code.
|
||||
+
|
||||
+ :param exit_code: The code to return upon exit.
|
||||
+ """
|
||||
+ commands = list()
|
||||
+
|
||||
+ # walk through all packages parallel to this script #
|
||||
+ paths = [os.path.realpath(os.path.dirname(__file__))]
|
||||
+ for importer, name, is_package in pkgutil.walk_packages(path=paths):
|
||||
+ # skip any objects that are packages (i.e. not modules) #
|
||||
+ if is_package:
|
||||
+ continue
|
||||
+
|
||||
+ try:
|
||||
+ importlib.import_module(name)
|
||||
+ except ModuleNotFoundError as e:
|
||||
+ # ignore any issues importing pytest, raise any other module import errors
|
||||
+ if e.name != "pytest":
|
||||
+ raise e
|
||||
+
|
||||
+ for subclass in Command.__subclasses__():
|
||||
+ # create a tuple of command details by calling the command_name() and command_desc() methods #
|
||||
+ command_details = (subclass().command_name(), subclass().command_desc())
|
||||
+ # add the command details to the list of discovered commands #
|
||||
+ commands.append(command_details)
|
||||
+
|
||||
+ # print the commands as well as the static help command to stdout #
|
||||
+ print()
|
||||
+ print(f"Usage: {os.path.basename(__file__)} <command> [options]")
|
||||
+ print()
|
||||
+ print("Commands:")
|
||||
+ for command in commands:
|
||||
+ print(" {:<30} {}".format(command[0], command[1]))
|
||||
+ help_cmd_display = f"-{_HELP_SHORT_OPT_}, --{_HELP_LONG_OPT_}"
|
||||
+ print(" {:<30} {}".format(help_cmd_display, "Display usage for viya-ark."))
|
||||
+ print()
|
||||
+
|
||||
+ sys.exit(exit_code)
|
||||
+
|
||||
+
|
||||
+##################
|
||||
+# __main__ #
|
||||
+##################
|
||||
+if __name__ == "__main__":
|
||||
+ main()
|
||||
diff --git a/viya_ark_library/templates/__init__.py b/viya_ark_library/templates/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
@@ -1,25 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "viya4-ark";
|
||||
version = "2.0.2";
|
||||
|
||||
src = fetchGit {
|
||||
url = "git@github.com:sassoftware/viya4-ark.git";
|
||||
ref = "main";
|
||||
rev = "6a7864cd25c39c2ba1e06adbbd94ecebf9a5e3bf";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./fix-setup.patch
|
||||
./remove-kubeconfig-check.patch
|
||||
];
|
||||
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [
|
||||
jinja2
|
||||
pint
|
||||
requests
|
||||
pyyaml
|
||||
ldap3
|
||||
semantic-version
|
||||
];
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
diff --git a/pre_install_report/library/pre_install_check.py b/pre_install_report/library/pre_install_check.py
|
||||
index 31b66d8..88a2d96 100644
|
||||
--- a/pre_install_report/library/pre_install_check.py
|
||||
+++ b/pre_install_report/library/pre_install_check.py
|
||||
@@ -218,21 +218,6 @@ class ViyaPreInstallCheck():
|
||||
output_dir)
|
||||
return
|
||||
|
||||
- def _read_environment_var(self, env_var):
|
||||
- """
|
||||
- This method verifies that the KUBECONFIG environment variable is set.
|
||||
-
|
||||
- :param env_var: Environment variable to check
|
||||
- """
|
||||
- try:
|
||||
- value_env_var = os.environ[env_var]
|
||||
- except Exception:
|
||||
- self.logger.exception("CalledProcessorError")
|
||||
- print(viya_messages.KUBECONF_ERROR)
|
||||
- sys.exit(viya_messages.BAD_ENV_RC_)
|
||||
-
|
||||
- return value_env_var
|
||||
-
|
||||
def _get_nested_info(self, nested_nodes, extracted_nodes, search_key):
|
||||
|
||||
try:
|
||||
diff --git a/pre_install_report/pre_install_report.py b/pre_install_report/pre_install_report.py
|
||||
index 1379c43..54fbc7e 100644
|
||||
--- a/pre_install_report/pre_install_report.py
|
||||
+++ b/pre_install_report/pre_install_report.py
|
||||
@@ -74,24 +74,6 @@ def _read_config_file(filename):
|
||||
sys.exit(viya_messages.SET_LIMTS_ERROR_RC_)
|
||||
|
||||
|
||||
-def read_environment_var(env_var):
|
||||
- """
|
||||
- This method verifies that the KUBECONFIG environment variable is set.
|
||||
-
|
||||
- :param env_var: Environment variable to check
|
||||
- """
|
||||
- try:
|
||||
- value_env_var = os.environ[env_var]
|
||||
- # Check if specified file exists
|
||||
- if not os.path.exists(value_env_var):
|
||||
- print(viya_messages.KUBECONF_FILE_ERROR.format(value_env_var))
|
||||
- sys.exit(viya_messages.BAD_ENV_RC_)
|
||||
- except Exception:
|
||||
- print(viya_messages.KUBECONF_ERROR)
|
||||
- sys.exit(viya_messages.BAD_ENV_RC_)
|
||||
- return value_env_var
|
||||
-
|
||||
-
|
||||
class PreInstallReportCommand(Command):
|
||||
"""
|
||||
Command implementation for the pre-install command to register
|
||||
@@ -198,7 +180,6 @@ def main(argv):
|
||||
|
||||
sas_logger = ViyaARKLogger(report_log_path, logging_level=logging_level, logger_name="pre_install_logger")
|
||||
logger = sas_logger.get_logger()
|
||||
- read_environment_var('KUBECONFIG')
|
||||
|
||||
try:
|
||||
kubectl = Kubectl(namespace=name_space)
|
||||
diff --git a/pre_install_report/test/test_pre_install_report.py b/pre_install_report/test/test_pre_install_report.py
|
||||
index ed805ec..f93ec58 100644
|
||||
--- a/pre_install_report/test/test_pre_install_report.py
|
||||
+++ b/pre_install_report/test/test_pre_install_report.py
|
||||
@@ -25,7 +25,6 @@ from pre_install_report.library.pre_install_check import ViyaPreInstallCheck
|
||||
from pre_install_report.library.pre_install_check_permissions import PreCheckPermissions
|
||||
from viya_ark_library.jinja2.sas_jinja2 import Jinja2TemplateRenderer
|
||||
from viya_ark_library.logging import ViyaARKLogger
|
||||
-from pre_install_report.pre_install_report import read_environment_var
|
||||
from pre_install_report.library.utils import viya_messages
|
||||
|
||||
_SUCCESS_RC_ = 0
|
||||
@@ -548,20 +547,6 @@ def test_get_calculated_aggregate_memory():
|
||||
assert str(round(total_calc_memoryGi.to('Gi'), 13)) == '62.5229606628418 Gi'
|
||||
|
||||
|
||||
-def test_kubconfig_file():
|
||||
- old_kubeconfig = os.environ.get('KUBECONFIG') # /Users/cat/doc
|
||||
- os.environ['KUBECONFIG'] = 'blah_nonexistentfile_blah'
|
||||
- new_kubeconfig = os.environ.get('KUBECONFIG') # /Users/cat/doc
|
||||
- assert new_kubeconfig == 'blah_nonexistentfile_blah'
|
||||
- try:
|
||||
- read_environment_var('KUBECONFIG')
|
||||
- except SystemExit as exc:
|
||||
- assert exc.code == viya_messages.BAD_ENV_RC_
|
||||
- pass
|
||||
- finally:
|
||||
- os.environ['KUBECONFIG'] = str(old_kubeconfig)
|
||||
-
|
||||
-
|
||||
def test_validated_k8s_server_version():
|
||||
|
||||
vpc = createViyaPreInstallCheck(viya_k8s_version_min,
|
@@ -1,155 +0,0 @@
|
||||
diff --git a/README.md b/README.md
|
||||
index db2292b..400fbc2 100644
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
@@ -24,7 +24,7 @@ Available Commands:
|
||||
license Download a license for the given order number at the given cadence name and version
|
||||
|
||||
Flags:
|
||||
- -c, --config string config file (default is $HOME/.viya4-orders-cli)
|
||||
+ -c, --config string config file (default is $XDG_CONFIG_HOME/viya4-orders-cli/config.yaml)
|
||||
-n, --file-name string name of the file where you want the downloaded order asset to be stored
|
||||
(defaults:
|
||||
certs - SASViyaV4_<order number>_certs.zip
|
||||
@@ -144,7 +144,7 @@ Take the following steps to start using SAS Viya Orders CLI:
|
||||
|
||||
1. If you want to use a configuration file, create it.
|
||||
|
||||
- The default location for the configuration file is `$HOME/.viya4-orders-cli`.
|
||||
+ The default location for the configuration file is `$XDG_CONFIG_HOME/viya4-orders-cli/config.yaml`.
|
||||
You can save the file anywhere you want as long as you use the `--config` /
|
||||
`-c` option to inform the CLI of any non-default location.
|
||||
|
||||
@@ -195,7 +195,7 @@ You have the following options for launching SAS Viya Orders CLI:
|
||||
The examples in this section correspond to typical tasks that you might perform
|
||||
using SAS Viya Orders CLI:
|
||||
|
||||
-- Using a configuration file, `/c/Users/auser/vocli/.viya4-orders-cli.yaml`, to
|
||||
+- Using a configuration file, `/c/Users/auser/vocli/.config/viya4-orders-cli/config.yaml`, to
|
||||
convey your API credentials, get deployment assets for SAS Viya order `923456`
|
||||
at the latest version of the Long Term Support (`lts`) cadence. Send the
|
||||
contents to file `/c/Users/auser/vocli/sasfiles/923456_lts_depassets.tgz`:
|
||||
@@ -203,13 +203,13 @@ using SAS Viya Orders CLI:
|
||||
|
||||
```docker
|
||||
docker run -v /c/Users/auser/vocli:/sasstuff viya4-orders-cli deploymentAssets 923456 lts \
|
||||
- --config /sasstuff/.viya4-orders-cli.yaml --file-path /sasstuff/sasfiles --file-name 923456_lts_depassets
|
||||
+ --config /sasstuff/.config/viya4-orders-cli/config.yaml --file-path /sasstuff/sasfiles --file-name 923456_lts_depassets
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
```text
|
||||
- 2020/10/02 19:16:30 Using config file: /sasstuff/.viya4-orders-cli.yaml
|
||||
+ 2020/10/02 19:16:30 Using config file: /sasstuff/.config/viya4-orders-cli/config.yaml
|
||||
OrderNumber: 923456
|
||||
AssetName: deploymentAssets
|
||||
AssetReqURL: https://api.sas.com/mysas/orders/923456/cadenceNames/lts/deploymentAssets
|
||||
diff --git a/cmd/root.go b/cmd/root.go
|
||||
index ad221c9..9707ed7 100644
|
||||
--- a/cmd/root.go
|
||||
+++ b/cmd/root.go
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
- homedir "github.com/mitchellh/go-homedir"
|
||||
"github.com/sassoftware/viya4-orders-cli/lib/authn"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@@ -48,7 +47,7 @@ func init() {
|
||||
|
||||
// Define global flags / options and set their default values.
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "",
|
||||
- "config file (default is $HOME/.viya4-orders-cli)")
|
||||
+ "config file (default is $XDG_CONFIG_HOME/viya4-orders-cli/config.yaml)")
|
||||
rootCmd.PersistentFlags().StringVarP(&assetFileName, "file-name", "n", "",
|
||||
"name of the file where you want the downloaded order asset stored\n"+
|
||||
"(defaults:\n\tcerts - SASViyaV4_<order number>_certs.zip\n\tlicense and depassets - SASViyaV4_<order number>_<renewal sequence>_<cadence information>_<asset name>_<date time stamp>."+
|
||||
@@ -74,16 +73,9 @@ func initConfig() {
|
||||
// Use config file from the flag.
|
||||
viper.SetConfigFile(cfgFile)
|
||||
} else {
|
||||
- // Find home directory.
|
||||
- home, err := homedir.Dir()
|
||||
- if err != nil {
|
||||
- log.Fatalln("ERROR: homedir.Dir() returned: " + err.Error())
|
||||
- }
|
||||
-
|
||||
- // Search config in home directory with name ".viya4-orders-cli" (without extension).
|
||||
- viper.AddConfigPath(home)
|
||||
- viper.SetConfigName(".viya4-orders-cli")
|
||||
- // If they provide a config file with no extension if must be in yaml format.
|
||||
+ viper.AddConfigPath("$XDG_CONFIG_HOME/viya4-orders-cli")
|
||||
+ viper.AddConfigPath("$HOME/.config/viya4-orders-cli")
|
||||
+ viper.SetConfigName("config")
|
||||
viper.SetConfigType("yaml")
|
||||
}
|
||||
|
||||
diff --git a/go.mod b/go.mod
|
||||
index fbb9bb4..5008b3b 100644
|
||||
--- a/go.mod
|
||||
+++ b/go.mod
|
||||
@@ -3,7 +3,6 @@ module github.com/sassoftware/viya4-orders-cli
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
- github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/spf13/viper v1.15.0
|
||||
golang.org/x/oauth2 v0.5.0
|
||||
diff --git a/go.sum b/go.sum
|
||||
index 2f4164a..507c254 100644
|
||||
--- a/go.sum
|
||||
+++ b/go.sum
|
||||
@@ -140,8 +140,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
-github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
-github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
|
||||
diff --git a/lib/authn/authn.go b/lib/authn/authn.go
|
||||
index a35c405..6345b6f 100644
|
||||
--- a/lib/authn/authn.go
|
||||
+++ b/lib/authn/authn.go
|
||||
@@ -7,10 +7,10 @@ package authn
|
||||
|
||||
import (
|
||||
"context"
|
||||
- "encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
+ "os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
@@ -26,15 +26,20 @@ const (
|
||||
|
||||
// GetBearerToken calls the /token SAS Viya Orders API endpoint to exchange client credentials for a Bearer token.
|
||||
// The client credentials are obtained from the SAS API Portal (https://apiportal.sas.com), and should be defined in
|
||||
-// Viper (https://github.com/spf13/viper) as clientCredentialsId (key) and clientCredentialsSecret (secret).
|
||||
+// Viper (https://github.com/spf13/viper) as clientCredentialsIdFile (key file) and clientCredentialsSecretFile (secret file).
|
||||
func GetBearerToken() (token string, err error) {
|
||||
- id, err := base64.StdEncoding.DecodeString(viper.GetString("clientCredentialsId"))
|
||||
+ idFile := viper.GetString("clientCredentialsIdFile")
|
||||
+ secFile := viper.GetString("clientCredentialsSecretFile")
|
||||
+
|
||||
+ // read id and sec from the files
|
||||
+ id, err := os.ReadFile(idFile)
|
||||
if err != nil {
|
||||
- return token, errors.New("ERROR: attempt to decode clientCredentialsId failed: " + err.Error())
|
||||
+ return token, errors.New("ERROR: attempt to read client credentials ID file failed: " + err.Error())
|
||||
}
|
||||
- sec, err := base64.StdEncoding.DecodeString(viper.GetString("clientCredentialsSecret"))
|
||||
+
|
||||
+ sec, err := os.ReadFile(secFile)
|
||||
if err != nil {
|
||||
- return token, errors.New("ERROR: attempt to decode clientCredentialsSecret failed: " + err.Error())
|
||||
+ return token, errors.New("ERROR: attempt to read client credentials secret file failed: " + err.Error())
|
||||
}
|
||||
|
||||
// Build the request URL.
|
@@ -1,26 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.buildGoModule rec {
|
||||
pname = "viya4-orders-cli";
|
||||
version = "1.6.0";
|
||||
|
||||
src = fetchGit {
|
||||
url = "git@github.com:sassoftware/viya4-orders-cli.git";
|
||||
ref = "main";
|
||||
rev = "44fb3c4f1c3773679592f0b923ac1d1945b976ec";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-iDNSV+oYNela4kFtkLppUIL5/hR1dEbPPuOlN5a5MfE=";
|
||||
|
||||
patches = [ ./better-config.patch ];
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X github.com/sassoftware/viya4-orders-cli/cmd.version=${version}"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp "$GOPATH/bin/viya4-orders-cli" $out/bin/viya4-orders-cli
|
||||
'';
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
{
|
||||
user ? throw "user argument is required",
|
||||
home ? throw "home argument is required",
|
||||
}:
|
||||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
selfPkgs = inputs.self.packages.${system};
|
||||
in
|
||||
{
|
||||
home-manager.users.${user}.home.packages = [ selfPkgs.viya4-ark ];
|
||||
}
|
@@ -2,8 +2,15 @@
|
||||
user ? throw "user argument is required",
|
||||
home ? throw "home argument is required",
|
||||
}:
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
selfPkgs = inputs.self.packages.${system};
|
||||
hmConfig = config.home-manager.users.${user};
|
||||
in
|
||||
{
|
||||
@@ -13,7 +20,7 @@ in
|
||||
"viya/orders-api/secret".sopsFile = ../../../../../../../secrets/sas/secrets.yaml;
|
||||
};
|
||||
|
||||
home.packages = [ (pkgs.callPackage ./package.nix { }) ];
|
||||
home.packages = [ selfPkgs.viya4-orders-cli ];
|
||||
|
||||
xdg.configFile."viya4-orders-cli/config.yaml".source =
|
||||
(pkgs.formats.yaml { }).generate "config.yaml"
|
@@ -82,14 +82,14 @@ in
|
||||
(import ./configs/console/kubernetes { inherit user home; })
|
||||
(import ./configs/console/podman { inherit user home; })
|
||||
(import ./configs/console/ssh { inherit user home; })
|
||||
(import ./configs/console/viya4-ark { inherit user home; })
|
||||
(import ./configs/console/viya4-orders-cli { inherit user home; })
|
||||
|
||||
(import ./configs/gui/obsidian { inherit user home; })
|
||||
(import ./configs/gui/vscode { inherit user home; })
|
||||
|
||||
# Private Imports
|
||||
(import ./configs/console/sage { inherit user home; })
|
||||
(import ./configs/console/viya-ark { inherit user home; })
|
||||
(import ./configs/console/viya-orders-cli { inherit user home; })
|
||||
];
|
||||
|
||||
# echo "password" | mkpasswd -s
|
||||
|
@@ -21,6 +21,7 @@
|
||||
../common/configs/system/nix-cleanup
|
||||
../common/configs/system/nix-install
|
||||
../common/configs/system/nix-ld
|
||||
../common/configs/system/nix-update
|
||||
../common/configs/system/nixpkgs
|
||||
../common/configs/system/ntp
|
||||
../common/configs/system/sops
|
||||
|
Reference in New Issue
Block a user