Compare commits

..

6 Commits

4 changed files with 67 additions and 19 deletions

View File

@ -16,6 +16,21 @@
"type": "github"
}
},
"my-flake": {
"locked": {
"lastModified": 1670879933,
"narHash": "sha256-V45PH0cnFLilx66x4td5qQnWNn/V/6/6b7FQDIHvdyI=",
"owner": "Jaculabilis",
"repo": "my-flake",
"rev": "2b2cd07a6d971b15fc5f65d6d963d0da551a5892",
"type": "github"
},
"original": {
"owner": "Jaculabilis",
"repo": "my-flake",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1669833724,
@ -35,6 +50,7 @@
"root": {
"inputs": {
"flake-compat": "flake-compat",
"my-flake": "my-flake",
"nixpkgs": "nixpkgs"
}
}

View File

@ -1,5 +1,6 @@
{
inputs = {
my-flake.url = "github:Jaculabilis/my-flake";
nixpkgs.url = "github:NixOS/nixpkgs?ref=refs/tags/22.11";
flake-compat = {
url = "github:edolstra/flake-compat";
@ -7,21 +8,43 @@
};
};
outputs = { self, nixpkgs, flake-compat }:
outputs = { self, my-flake, nixpkgs, flake-compat }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.${system}.default =
(pkgs.poetry2nix.mkPoetryApplication {
projectDir = ./.;
}).dependencyEnv;
systems = [ "aarch64-linux" "x86_64-linux" ];
each = system:
let
pkgs = (import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
});
in {
packages.${system} = {
default = self.packages.${system}.inquisitor;
inquisitor = pkgs.inquisitor;
env = pkgs.inquisitor.dependencyEnv;
};
defaultPackage.${system} = self.packages.${system}.default;
devShell.${system} = pkgs.mkShell {
devShells.${system} = {
default = self.devShells.${system}.inquisitor;
inquisitor = pkgs.mkShell {
buildInputs = [ (pkgs.python3.withPackages (p: [p.poetry])) ];
shellHook = ''
PS1="(inquisitor) $PS1"
'';
};
sources = pkgs.mkShell {
buildInputs = [ self.packages.${system}.env ];
shellHook = ''
PS1="(sources) $PS1"
'';
};
};
};
in (my-flake.outputs-for each systems) // {
overlays.default = final: prev: {
inquisitor = final.poetry2nix.mkPoetryApplication {
projectDir = ./.;
};
};
};
}

View File

@ -236,6 +236,11 @@ def command_help(args):
return 0
def nocommand(args):
print("command required")
return 0
def main():
"""CLI entry point"""
# Enable piping
@ -283,8 +288,11 @@ def main():
add_logging_handler(verbose=args.verbose, log_filename=None)
# Execute command
if args.command:
sys.exit(commands[args.command](args.args))
else:
print("command required")
sys.exit(0)
try:
command = commands.get(args.command, nocommand)
sys.exit(command(args.args))
except BrokenPipeError:
# See https://docs.python.org/3.10/library/signal.html#note-on-sigpipe
devnull = os.open(os.devnull, os.O_WRONLY)
os.dup2(devnull, sys.stdout.fileno())
sys.exit(1)

View File

@ -42,7 +42,8 @@ def read_config_file(config_path):
"""
# Parse the config file into key-value pairs
if not os.path.isfile(config_path):
raise FileNotFoundError(f'No config file found at {config_path}')
raise FileNotFoundError(f'No config file found at {config_path}, try setting {CONFIG_ENVVAR}')
accumulated_configs = {}
current_key = None
with open(config_path, 'r', encoding='utf8') as cfg: