Compare commits

...

6 Commits

4 changed files with 67 additions and 19 deletions

View File

@ -16,6 +16,21 @@
"type": "github" "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1669833724, "lastModified": 1669833724,
@ -35,6 +50,7 @@
"root": { "root": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"my-flake": "my-flake",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View File

@ -1,5 +1,6 @@
{ {
inputs = { inputs = {
my-flake.url = "github:Jaculabilis/my-flake";
nixpkgs.url = "github:NixOS/nixpkgs?ref=refs/tags/22.11"; nixpkgs.url = "github:NixOS/nixpkgs?ref=refs/tags/22.11";
flake-compat = { flake-compat = {
url = "github:edolstra/flake-compat"; url = "github:edolstra/flake-compat";
@ -7,21 +8,43 @@
}; };
}; };
outputs = { self, nixpkgs, flake-compat }: outputs = { self, my-flake, nixpkgs, flake-compat }:
let let
system = "x86_64-linux"; systems = [ "aarch64-linux" "x86_64-linux" ];
pkgs = nixpkgs.legacyPackages.${system}; each = system:
in let
{ pkgs = (import nixpkgs {
packages.${system}.default = inherit system;
(pkgs.poetry2nix.mkPoetryApplication { overlays = [ self.overlays.default ];
projectDir = ./.; });
}).dependencyEnv; in {
packages.${system} = {
default = self.packages.${system}.inquisitor;
inquisitor = pkgs.inquisitor;
env = pkgs.inquisitor.dependencyEnv;
};
defaultPackage.${system} = self.packages.${system}.default; devShells.${system} = {
default = self.devShells.${system}.inquisitor;
devShell.${system} = pkgs.mkShell { inquisitor = pkgs.mkShell {
buildInputs = [ (pkgs.python3.withPackages (p: [p.poetry])) ]; 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 return 0
def nocommand(args):
print("command required")
return 0
def main(): def main():
"""CLI entry point""" """CLI entry point"""
# Enable piping # Enable piping
@ -283,8 +288,11 @@ def main():
add_logging_handler(verbose=args.verbose, log_filename=None) add_logging_handler(verbose=args.verbose, log_filename=None)
# Execute command # Execute command
if args.command: try:
sys.exit(commands[args.command](args.args)) command = commands.get(args.command, nocommand)
else: sys.exit(command(args.args))
print("command required") except BrokenPipeError:
sys.exit(0) # 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 # Parse the config file into key-value pairs
if not os.path.isfile(config_path): 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 = {} accumulated_configs = {}
current_key = None current_key = None
with open(config_path, 'r', encoding='utf8') as cfg: with open(config_path, 'r', encoding='utf8') as cfg: