Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: prepare for poetry2nix removal/nixops packaging changes in nixpkgs #1569

Merged
merged 8 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/release-notes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ This a minor bugfix release.
completed. Previously this was done before, but that could lead to
volumes not being able to detach without needing to stop the machine.

- Added a command-line option ``--repair`` as a convient way to pass this
- Added a command-line option ``--repair`` as a convenient way to pass this
option, which allows repairing of broken or changed paths in the nix
store, to nix-build calls that nixops performs. Note that this option
only works in nix setups that run without the nix daemon.
Expand Down
710 changes: 408 additions & 302 deletions doc/requirements.txt

Large diffs are not rendered by default.

109 changes: 102 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 11 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
description = "NixOps: a tool for deploying to [NixOS](https://nixos.org) machines in a network or the cloud";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";

inputs.poetry2nix.url = "github:nix-community/poetry2nix";
inputs.poetry2nix.inputs.nixpkgs.follows = "nixpkgs";

inputs.utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: let
outputs = { self, nixpkgs, poetry2nix, utils }: utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { inherit system; };
poetry2nix' = import poetry2nix { inherit pkgs; };

pythonEnv = (pkgs.poetry2nix.mkPoetryEnv {
pythonEnv = poetry2nix'.mkPoetryEnv {
projectDir = ./.;
overrides = [
pkgs.poetry2nix.defaultPoetryOverrides
(import ./overrides.nix { inherit pkgs; })
];
});
};
linters.doc = pkgs.writers.writeBashBin "lint-docs" ''
set -eux
# When running it in the Nix sandbox, there is no git repository
Expand Down Expand Up @@ -57,22 +57,14 @@

defaultApp = apps.default;

packages.default = let
overrides = import ./overrides.nix { inherit pkgs; };

in pkgs.poetry2nix.mkPoetryApplication {
packages.default = poetry2nix'.mkPoetryApplication {
projectDir = ./.;

propagatedBuildInputs = [
pkgs.openssh
pkgs.rsync
];

overrides = [
pkgs.poetry2nix.defaultPoetryOverrides
overrides
];

# TODO: Re-add manual build
};

Expand Down Expand Up @@ -118,7 +110,7 @@
name = "nixops-docs";
# we use cleanPythonSources because the default gitignore
# implementation doesn't support the restricted evaluation
src = pkgs.poetry2nix.cleanPythonSources {
src = poetry2nix'.cleanPythonSources {
src = ./.;
};

Expand All @@ -138,7 +130,7 @@
name = "check-lint-docs";
# we use cleanPythonSources because the default gitignore
# implementation doesn't support the restricted evaluation
src = pkgs.poetry2nix.cleanPythonSources {
src = poetry2nix'.cleanPythonSources {
src = ./.;
};
dontBuild = true;
Expand Down
8 changes: 4 additions & 4 deletions nixops/nix_expr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import abstractmethod
import functools
import string
from typing import Iterable, Optional, Any, List, Tuple, Union, Dict
from typing import Iterable, Optional, Any, List, Sequence, Tuple, Union, Dict
from textwrap import dedent

__all__ = ["py2nix", "nix2py", "nixmerge", "expand_dict", "RawValue", "Function"]
Expand Down Expand Up @@ -81,12 +81,12 @@ class Container(object):
def __init__(
self,
prefix: str,
children: List,
children: Sequence[Union[RawValue, "Container"]],
suffix: str,
inline_variant: Optional[ValueLike] = None,
):
self.prefix: str = prefix
self.children: List = children
self.children = children
self.suffix: str = suffix
self.inline_variant = inline_variant

Expand All @@ -99,7 +99,7 @@ def get_min_length(self) -> int:
+ len(self.suffix)
+ 1
+ len(self.children)
+ sum([child.get_min_length() for child in self.children])
+ sum([child.get_min_length() or 0 for child in self.children])
)

def is_inlineable(self) -> bool:
Expand Down
1 change: 1 addition & 0 deletions nixops/plugins/hookspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ def plugin() -> Plugin:
"""
Register a plugin base class
"""
raise NotImplementedError
7 changes: 3 additions & 4 deletions nixops/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import logging
import atexit
import re
import typing
import typeguard # type: ignore
import inspect
import shlex
Expand Down Expand Up @@ -139,9 +140,7 @@ def __init__(self, *args: ImmutableValidatedObject, **kwargs):
# Support inheritance
anno: Dict = {}
for x in reversed(self.__class__.mro()):
if not hasattr(x, "__annotations__"):
continue
anno.update(x.__annotations__)
anno.update(typing.get_type_hints(x))

def _transform_value(key: Any, value: Any) -> Any:
ann = anno.get(key)
Expand All @@ -166,7 +165,7 @@ def _transform_value(key: Any, value: Any) -> Any:
new_value.append(v)
value = tuple(new_value)

typeguard.check_type(key, value, ann)
typeguard.check_type(value, ann)

return value

Expand Down
14 changes: 0 additions & 14 deletions overrides.nix

This file was deleted.

Loading
Loading