Initial commit
This commit is contained in:
commit
8bfb2256f8
7 changed files with 239 additions and 0 deletions
52
flake.nix
Normal file
52
flake.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
description = "Provides containerized opencode";
|
||||
|
||||
outputs = inputs@{ ... }: {
|
||||
flakeModule = { self, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (flake-parts-lib) mkPerSystemOption;
|
||||
inherit (lib) mkOption mkEnableOption types;
|
||||
in {
|
||||
options.perSystem = mkPerSystemOption ({ pkgs, system, ...}: {
|
||||
options.ocd = {
|
||||
enable = mkEnableOption "Containerized opencode";
|
||||
ocUrl = mkOption {
|
||||
type = types.str;
|
||||
default = "https://registry.npmjs.org/opencode-linux-x64/-/opencode-linux-x64-1.0.129.tgz";
|
||||
description = "URL of the opencode tarball";
|
||||
};
|
||||
ocSha256 = mkOption {
|
||||
type = types.str;
|
||||
default = "sha256:0md8iq7fk6nr3qfbljzyghnz1v0hqqjsmdwp1icql7l1a8nfa09z";
|
||||
description = "SHA256 hash of the opencode tarball";
|
||||
};
|
||||
withPackages = mkOption {
|
||||
type = types.functionTo (types.listOf types.package);
|
||||
default = p: [];
|
||||
description = "Extra packages to include in the container";
|
||||
example = lib.literalExpression "p: [ p.tmux ]";
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
config = {
|
||||
perSystem = { config, pkgs, system, ...}:
|
||||
lib.mkIf config.ocd.enable {
|
||||
devShells.default = pkgs.mkShell {
|
||||
shellHook = ''
|
||||
set -v
|
||||
alias ocd-init='$(nix build .#ocd --print-out-paths) | docker load'
|
||||
alias ocd-start='docker run -it --rm -v $(pwd):/workspace -v $(pwd)/.oc-local:/root/.local/share/opencode --network host ocd:latest'
|
||||
set +v
|
||||
echo 'ocd-init needs to be ran once (or on image change)'
|
||||
'';
|
||||
};
|
||||
|
||||
packages.ocd = pkgs.callPackage ./image.nix {
|
||||
inherit (config.ocd) withPackages ocUrl ocSha256;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue