Files
ad-nix/flake.nix
John Lancaster e80a85c490 big refactor
2024-12-18 00:52:36 -06:00

141 lines
4.1 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 = {
userName = "appdaemon";
gitUserName = "John Lancaster";
gitUserEmail = "32917998+jsl12@users.noreply.github.com";
adRepo = "https://github.com/jsl12/appdaemon";
adBranch = "hass";
adHome = "/srv/appdaemon";
};
systemSettings = {
hostName = "ad-nix";
stateVersion = "24.05";
system = "x86_64-linux";
timeZone = "America/Chicago";
locale = "en_US.UTF-8";
pythonVersion = "3.12.7";
};
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
];
};
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
pre-commit.hooks = {
end-of-file-fixer.enable = true;
trim-trailing-whitespace.enable = true;
};
languages.python = {
enable = true;
version = systemSettings.pythonVersion;
uv = {
enable = true;
sync = {
enable = true;
allExtras = true;
arguments = [ "-U" ];
};
};
};
packages = with pkgs; [
git
# (writeShellScriptBin "full-build" ''
# cd ${adPath}
# ${pkgs.uv}/bin/uv build --wheel
# docker build -t acockburn/appdaemon:local-dev ${adPath}
# '')
# (pkgs.python312.withPackages (python-pkgs: with python-pkgs; [
# pip
# setuptools
# wheel
# ipykernel
# rich
# ]))
];
enterShell = ''
alias appdaemon="${pkgs.uv}/bin/uv run --frozen python -m appdaemon"
alias ad="appdaemon"
export PS1="\[\e[0;34m\](AppDaemon)\[\e[0m\] ''${PS1-}"
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: \e[32m$(${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"
'';
})
];
};
};
}