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

[#526] Implementing Nix Flakes to combine application modules for root project access #529

Conversation

placek
Copy link
Contributor

@placek placek commented Mar 21, 2024

Closes #526.

In this pull request, the implementation includes the addition of Nix Flakes to combine application modules for easy access and utilization from the root of the project, as per the user story requirement. The commit message details the changes made to achieve this, incorporating modules, environments, and configurations to align with the intended goal. By leveraging Nix Flakes, developers can enhance project manageability and organization.

The overall outcome of these changes results in a structured project setup that allows for a streamlined process of combining application modules using Nix Flakes. The modifications specifically involve setting up Nix Flakes configurations, establishing module-specific .envrc files, relocating environment definitions, and integrating backend and infrastructure environments as outputs. Additionally, improvements in documentation and handling package warnings contribute to a more efficient development environment.

These enhancements aim to simplify the setup process, provide clear instructions for utilizing Nix, and ensure cohesion among various project components, ultimately leading to improved project structure and ease of use for developers.

@placek placek self-assigned this Mar 21, 2024
@placek placek force-pushed the chore/526-implementing-nix-flakes-to-combine-application-modules-for-root-project-access branch 2 times, most recently from d00b125 to a7bad07 Compare March 22, 2024 08:03
@placek placek marked this pull request as ready for review March 22, 2024 08:04
Implementing Nix Flakes requires the creation of a default entrypoint
for scripts to ensure that that application module can be effectively
combined within the project structure. This default.nix file includes a
shell definition with necessary build inputs such as awscli, curl,
docker, git, gnumake, openssh, and rsync. By adding this default
entrypoint, developers can utilize Nix Flakes to streamline the
combination of application modules within the project.
The commit introduces a `flake.lock` and `flake.nix` file, defining the
project's dependencies and configuration. The `flake.nix` file sets up a
Nix Flake for the GovTool and utilities monorepo, specifying inputs from
nixpkgs and generating packages for supported systems such as
x86_64-linux, aarch64-linux, x86_64-darwin, and aarch64-darwin.
Additionally, the `scripts` attribute is included to allow for a scripts
environment from `scripts/govtool`, ensuring a versatile Nix-shell setup
for all supported systems.
The user story requires utilizing Nix Flakes to combine application
modules within a project to enhance manageability and organization. In
this commit, the .envrc example was relocated from
`scripts/govtool/.env.example` to the root directory as `.env.example`.
By moving this file, we align with the objective of making the
application modules accessible from the root of the project. The
modification ensures that the necessary environment configuration
template is centrally located, facilitating the use of Nix Flakes for
streamlined module combination.

Changes:
- The `.envrc` example file has been moved from
  `scripts/govtool/.env.example` to the project's root directory as
  `.env.example`.
- The file contents were adjusted to remove references to the previous
  directory structure and updated to indicate the use of Nix Flakes
  configuration.
- The relocation enhances accessibility and clarity, aligning with the
  goal of effectively combining application modules using Nix Flakes for
  improved project structure and management.
The user story necessitates utilizing Nix Flakes to combine application
modules within the project for better organization and manageability.
This commit integrates the backend environment into the Nix Flakes as
one of the outputs, aligning with the objective of enhancing
accessibility and usability of application modules from the project's
root. By adding the backend as an output, developers can effectively
combine and utilize the backend environment using Nix Flakes for
improved project structure and management.

Changes:
- Added the backend environment as an output in the `flake.nix` file.
- Modified `govtool/backend/default.nix` to include the recommended
  Haskell compiler version and additional tools needed for the backend.
- Updated the entrypoint to provide necessary build inputs and display a
  welcome message for the backend development shell.
- Removed unnecessary files `shell.nix` and `sources.nix` related to the
  backend environment setup.
Integrating the infrastructure environment into the Nix Flakes
configuration is crucial for combining application modules effectively
within the project structure. By updating the `flake.nix` file, the
infrastructure environment is now part of the Nix Flakes configuration,
enabling streamlined access and utilization of infrastructure-related
tools. The changes include incorporating the infrastructure package in
the `flake.nix` file, moving `default.nix` to infra/terraform directory,
and removing unnecessary files related to the shell environment setup.
This enhancement aligns with the user story's goal of utilizing Nix
Flakes to combine application modules for improved project organization
and accessibility.

Changes:
- Added the infrastructure package to the `flake.nix` configuration for
  Nix Flakes.
- Moved `default.nix` to the `infra/terraform` directory to establish
  the infrastructure environment setup within the project.
- Removed unnecessary files related to the shell environment setup in
  the `infra/terraform` directory to streamline the project structure.
The purpose of this commit is to create .envrc files within specific
modules that reference the root .envrc file and utilize the
corresponding flake for configuration. By establishing these .envrc
files in the `backend`, `infra`, and `scripts` modules, the project
enhances the organization and management of application modules using
Nix Flakes. This setup ensures that each module aligns with the root
configuration, streamlining the usage of Nix Flakes for combining
application modules effectively within the project structure.

Changes:
- Renamed .env.example to .envrc.example, ensuring consistency in naming
  conventions.
- Added a new .envrc file in the `govtool/backend` directory,
  referencing the root environment and using the corresponding flake for
  the backend module.
- Created a .envrc file in the `infra/terraform` directory, linking to
  the root environment and utilizing the appropriate flake for the
  infrastructure module.
- Introduced a .envrc file in the `scripts/govtool` directory, pointing
  to the root environment and leveraging the matching flake for the
  scripts module setup.
…f the project

The relocation of the DOMAIN definition from the subdirectory specific
.envrc files to the master .envrc file in the root directory streamlines
the access to and management of environment variables within the
project. As per the user story requirements to enhance organization and
accessibility of application modules using Nix Flakes, this adjustment
ensures that the domain configuration is centralized, simplifying the
integration of the application modules. By consolidating this setting in
the main .envrc file, developers can effectively coordinate and utilize
the domain configuration across different project components, aligning
with the goal of leveraging Nix Flakes for improved project structure
and ease of use.

Changes:
- Moved the DOMAIN definition logic from individual .envrc files to the
  main .envrc file in the project's root directory.
- Updated the .envrc.example file to reflect the changes in domain
  configuration logic for different environments.
- Streamlined domain configuration setups for various environments (dev,
  test, staging, beta) within the central .envrc file, enhancing clarity
  and accessibility for developers working on the project.
Integrating a frontend module into the Nix Flakes configuration is
essential for combining application modules within the project
effectively. The frontend module's addition is in alignment with the
user story's goal of utilizing Nix Flakes to enhance project
manageability and organization. By including the frontend module,
developers can streamline the usage and integration of frontend-related
tools and configurations, fostering a cohesive structure for the
application. This commit expands the project's capabilities by
incorporating a frontend module into the Nix Flakes setup.

Changes:
- Integrated the `node_nixpkgs` input to the `flake.nix` file, allowing
  for frontend-specific dependencies in the Nix Flakes configuration.
- Created a `.envrc` file within the `govtool/frontend` directory,
  defining environment variables for the frontend module and setting up
  the necessary configurations.
- Updated the Dockerfile in the `govtool/frontend` directory to include
  variables related to the Vite base URL and other frontend settings.
- Adjusted the `default.nix` file in the `govtool/frontend` directory to
  enhance the frontend project configuration and provide a tailored
  development shell setup. The update includes a welcome message and
  necessary cleanup processes for improved project development
  experiences.
Provide comprehensive documentation on utilizing Nix with the project to
enhance development processes and streamline environment setup. The
.envrc files are updated to ensure compatibility with Nix
configurations, facilitating package installation and project building.
This documentation emphasizes the use of Nix and Direnv for effective
project setup and module combination within the GovTool project
structure.

Changes:
- Updated `README.md` in `govtool/backend` to include instructions for
  utilizing Nix and Direnv, aligning the setup with Nix Flakes
  configuration.
- Revised `README.md` in `govtool/frontend` to streamline instructions
  for using Nix and Direnv, ensuring proper environment setup and
  dependencies for the frontend module development.
Implementing Nix Flakes is essential to combine application modules
within the project, ensuring easy access and utilization from the root
directory. By adding the Nix Flakes configuration in this commit,
developers can streamline the setup process for various modules,
enhancing project manageability and organization. This aligns with the
user story's goal of leveraging Nix Flakes for improved accessibility to
and usage of application modules.

Changes:
- Included Nix Flakes configuration to manage unified developer setups
  effectively.
- Enhanced the project structure by enabling easy access and utilization
  of application modules from the root directory.
- Streamlined the setup process for different modules, ensuring
  consistency and ease of use within the project environment.
@placek placek force-pushed the chore/526-implementing-nix-flakes-to-combine-application-modules-for-root-project-access branch from a7bad07 to 68d654d Compare March 22, 2024 13:19
@placek placek merged commit 2ef2374 into develop Mar 22, 2024
3 of 4 checks passed
@placek placek deleted the chore/526-implementing-nix-flakes-to-combine-application-modules-for-root-project-access branch March 22, 2024 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementing Nix Flakes to combine application modules for root project access
2 participants