146 lines
4.9 KiB
Nix
146 lines
4.9 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
home-manager = {
|
|
url = "github:nix-community/home-manager";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
vscode-server.url = "github:nix-community/nixos-vscode-server";
|
|
sops-nix = {
|
|
url = "github:Mic92/sops-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
nixpkgs-python = {
|
|
url = "github:cachix/nixpkgs-python";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
devenv = {
|
|
url = "github:cachix/devenv";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
nixConfig = {
|
|
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
|
|
extra-substituters = "https://devenv.cachix.org";
|
|
};
|
|
|
|
outputs = { self, ... }@args:
|
|
let
|
|
inherit (self) outputs;
|
|
nixosSystem = args.nixpkgs.lib.nixosSystem;
|
|
|
|
userSettings = {
|
|
gitUserName = "John Lancaster";
|
|
gitUserEmail = "32917998+jsl12@users.noreply.github.com";
|
|
userName = "appdaemon";
|
|
adHome = "/home/appdaemon";
|
|
};
|
|
|
|
systemSettings = {
|
|
hostName = "ad-nix";
|
|
stateVersion = "24.05";
|
|
system = "x86_64-linux";
|
|
timeZone = "America/Chicago";
|
|
locale = "en_US.UTF-8";
|
|
# pythonVersion = "3.11.10"; # This is largely irrelevant because uv will handle it
|
|
};
|
|
|
|
pkgs = args.nixpkgs.legacyPackages.${systemSettings.system};
|
|
|
|
in
|
|
{
|
|
nixosConfigurations.${systemSettings.hostName} = nixosSystem {
|
|
system = systemSettings.system;
|
|
specialArgs =
|
|
let
|
|
inputs = args;
|
|
in
|
|
{
|
|
inherit inputs;
|
|
inherit systemSettings;
|
|
inherit userSettings;
|
|
};
|
|
modules = [
|
|
(args.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix")
|
|
args.home-manager.nixosModules.default
|
|
args.vscode-server.nixosModules.default
|
|
args.sops-nix.nixosModules.sops
|
|
./configuration.nix
|
|
];
|
|
};
|
|
|
|
# https://devenv.sh/guides/using-with-flakes/#the-flakenix-file
|
|
packages.${systemSettings.system} = {
|
|
devenv-up = self.devShells.${systemSettings.system}.default.config.procfileScript;
|
|
devenv-test = self.devShells.${systemSettings.system}.default.config.test;
|
|
};
|
|
|
|
devShells.${systemSettings.system}.default =
|
|
let
|
|
inputs = args;
|
|
in
|
|
args.devenv.lib.mkShell {
|
|
inherit inputs pkgs;
|
|
modules = [
|
|
({ pkgs, config, ... }: {
|
|
# This is your devenv configuration
|
|
|
|
# https://devenv.sh/reference/options/#pre-commithooks
|
|
git-hooks.hooks = {
|
|
end-of-file-fixer.enable = true;
|
|
trim-trailing-whitespace.enable = true;
|
|
};
|
|
|
|
# https://devenv.sh/supported-languages/python/
|
|
languages.python = {
|
|
enable = true;
|
|
# version = systemSettings.pythonVersion;
|
|
uv = {
|
|
enable = true;
|
|
package = pkgs.uv;
|
|
sync = {
|
|
enable = true;
|
|
allExtras = true;
|
|
arguments = [ "-U" ];
|
|
};
|
|
};
|
|
};
|
|
|
|
packages = with pkgs; [
|
|
git
|
|
gdbm
|
|
# (python312.withPackages (python-pkgs: with python-pkgs; [ gdbm ]))
|
|
(python312.withPackages (python-pkgs: with python-pkgs; [
|
|
gdbm
|
|
notebook # kinda hacky, but needed so that jupyter notebook has some shared library it needs?
|
|
]))
|
|
(writeShellScriptBin "docs" "${pkgs.uv}/bin/uv run sphinx-autobuild -E ./docs/ ./docs_build --port 9999")
|
|
(writeShellScriptBin "ab" "${pkgs.uv}/bin/uv build --wheel --refresh")
|
|
(writeShellScriptBin "adb" "ab && ${pkgs.docker}/bin/docker build -t acockburn/appdaemon:local-dev .")
|
|
# (writeShellScriptBin "ad-nb" "cd $(readlink -f /etc/nixos) && devenv up")
|
|
];
|
|
|
|
# processes = {
|
|
# my-jup.exec = "uv run jupyter notebook";
|
|
# };
|
|
|
|
enterShell = ''
|
|
alias fix="${pkgs.uv}/bin/uv run ruff check --fix"
|
|
alias appdaemon="${pkgs.uv}/bin/uv run --frozen appdaemon"
|
|
# alias ad="appdaemon"
|
|
|
|
export PS1="\[\e[0;34m\](AppDaemon)\[\e[0m\] \[\033[1;32m\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\$\[\033[0m\] "
|
|
|
|
export VIRTUAL_ENV=$UV_PROJECT_ENVIRONMENT
|
|
|
|
echo -e "URL: \e[34m$(${pkgs.git}/bin/git config --get remote.origin.url)\e[0m"
|
|
echo -e "Branch/Tag: \e[32m$(${pkgs.git}/bin/git describe --tags --exact-match 2>/dev/null || ${pkgs.git}/bin/git rev-parse --abbrev-ref HEAD)\e[0m"
|
|
echo -e "Hash: \e[33m$(${pkgs.git}/bin/git rev-parse --short HEAD)\e[0m"
|
|
echo "AppDaemon v$(${pkgs.uv}/bin/uv pip show appdaemon | awk '/^Version:/ {print $2}') development shell started"
|
|
'';
|
|
})
|
|
];
|
|
};
|
|
};
|
|
} |