Skip to content

Commit

Permalink
bug: fix WSL store startup crash
Browse files Browse the repository at this point in the history
docs: overhaul
  • Loading branch information
htngr committed Dec 6, 2024
1 parent dd2232e commit b01244a
Show file tree
Hide file tree
Showing 53 changed files with 13,398 additions and 8,740 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
</p>

[![build-windows](https://github.com/aformatik/codchi/actions/workflows/build-windows.yml/badge.svg)](https://github.com/aformatik/codchi/actions/workflows/build-windows.yml)
![GitHub](https://img.shields.io/github/license/aformatik/codchi)
![Version](https://img.shields.io/github/v/release/aformatik/codchi)
![Contributions Welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)

Codchi is a tool that manages your project's development environment in a reproducible and easy-to-use way. Setting up a development environment should be as easy as a `git clone`!

Expand All @@ -16,4 +19,22 @@ Read [What is Codchi?](https://codchi.dev/docs/start/intro.html) for an introduc

## Contributing

Make sure to read [Architecture](https://codchi.dev/docs/contrib/architecture.html) to understand how Codchi works under the hood.
Make sure to read [Internals](https://codchi.dev/docs/contrib/internals.html) to understand how Codchi works under the hood.

## Support

Codchi is a fully open-source project building on open foundations like NixOS modules. There is no vendor lock-in or open-core model. Codchi is funded through its use at aformatik as well as through professional support, training, and consulting services.

### Community Support

For community support, we encourage users to engage through our GitHub page:

- **Feature Requests & Issues**: Report bugs, suggest new features, or ask questions via [GitHub Issues](https://github.com/aformatik/codchi/issues).

### Professional Support

For professional support, please contact [aformatik](https://aformatik.de/kontakt):

- **Feature Requests & Issues**: We offer dedicated assistance for feature requests, bug fixes, and troubleshooting.
- **Training and Consulting**: Need help building a tailored *code machine* for your organization? We provide specialized training and consulting services to help you leverage Codchi to its full potential in your environment.

1 change: 1 addition & 0 deletions codchi/src/platform/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl Store for StoreImpl {
store
.cmd()
.run("/sbin/init", &[])
.with_cwd(LinuxPath("/".to_string()))
.output_ok_streaming(channel().1, |line| {
log_progress("store_init", Level::Debug, &line)
})?;
Expand Down
14 changes: 14 additions & 0 deletions docs/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
root: true,
extends: ['@nuxt/eslint-config'],
ignorePatterns: [
'dist',
'node_modules',
'.output',
'.nuxt'
],
rules: {
'vue/max-attributes-per-line': 'off',
'vue/multi-word-component-names': 'off'
}
}
14 changes: 12 additions & 2 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
node_modules
doc_build
flake.lock
node_modules
*.iml
.idea
*.log*
.nuxt
.vscode
.DS_Store
coverage
dist
sw.*
.env
.output
1 change: 1 addition & 0 deletions docs/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
strict-peer-dependencies=false
32 changes: 32 additions & 0 deletions docs/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// https://github.com/nuxt-themes/docus/blob/main/nuxt.schema.ts
export default defineAppConfig({
docus: {
title: 'Codchi',
description: 'Reproducible and Reliable Development Environments',
socials: {
github: 'aformatik/codchi',
},
github: {
dir: 'docs',
branch: 'master',
repo: 'codchi',
owner: 'aformatik',
edit: true
},
aside: {
level: 0,
collapsed: false,
exclude: []
},
main: {
padded: true,
fluid: true
},
header: {
logo: true,
showLinkIcon: true,
exclude: [],
fluid: true
}
}
})
6 changes: 6 additions & 0 deletions docs/components/Logo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<div style="display: flex; align-items: center; gap: 0.5rem; height: 2rem">
<img style="height:100%" src="/favicon.ico" alt="Codchi Logo"/>
<span style="font-size: var(--text-xl-fontSize); line-height: var(--text-xl-lineHeight); font-weight: var(--fontWeight-bolder); letter-spacing: var(--letterSpacing-tight);">Codchi</span>
</div>
</template>
108 changes: 108 additions & 0 deletions docs/content/0.index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: Reproducible and Reliable Development Environments
navigation: false
layout: page
main:
fluid: false
---

:ellipsis{right=0px width=75% blur=150px}

::block-hero
---
cta:
- Get started
- /introduction/what-is-codchi
secondary:
- Open on GitHub →
- https://github.com/aformatik/codchi
---


#title
Reproducible and Reliable Development Environments

#description

Codchi is a tool that manages your project's development environment in a reproducible and easy-to-use way. Setting up a development environment should be as easy as a `git clone`!

::alert{type="warning"}
Codchi is currently in beta and still under active development and testing. Please expect potential bugs and incomplete features. We welcome feedback and contributions to help improve stability and functionality!
::



<!-- #extra -->
<!-- ::list -->
<!-- - **+50 Components** ready to build rich pages -->
<!-- - **Docs** and **Page** layouts -->
<!-- - Start from a `README`, scale to a framework documentation -->
<!-- - Navigation and Table of Contents generation -->
<!-- - Fully configurable design system -->
<!-- - Leverages [**Typography**](https://typography.nuxt.space/) and [**Elements**](https://elements.nuxt.dev) -->
<!-- - Used on [Content Documentation](https://content.nuxtjs.org) -->
<!-- :: -->

#support
:video-player{src="https://www.youtube.com/watch?v=o9e12WbKrd8"}
<!-- ::terminal -->
<!-- --- -->
<!-- content: -->
<!-- - npx nuxi@latest init -t themes/docus -->
<!-- - cd docs -->
<!-- - npm install -->
<!-- - npm run dev -->
<!-- --- -->
<!-- :: -->
::

::card-grid
#title
Codchi's features

#root
:ellipsis{left=0px width=40rem top=10rem blur=140px}

#default
::card{icon=noto:snowflake}
#title
Reproducible and Reliable
#description
Codchi builds on the excellent Nix package manager to install, update, and roll back your project's development environment. This means bit-for-bit reproducible environments on any machine.
::

::card{icon=noto:gear}
#title
Declarative
#description
Code Machines are defined in code and checked into your repository, allowing you to check out the correct environment at every commit of your project.
::

::card{icon=noto:unlocked}
#title
Built on Standards
#description
We didn't reinvent the wheel - every NixOS module is a valid Code Machine. Also, every Code Machine is a valid NixOS module, so you're not locked into Codchi.
::

::card{icon=noto:magic-wand}
#title
Easy to install
#description
Installing a Code Machine is as easy as copying and pasting the link to the project repository into Codchi and waiting a few minutes for the installation process to complete.
::

::card{icon=noto:feather}
#title
Easy to use
#description
Once installed, shortcuts to graphical programs will appear in your start menu, or you can access a shell containing all available tools.
::

::card{icon=noto:laptop}
#title
Native and Cross Platform
#description
Native Looks and Performance on Windows 10, Windows 11 and Linux. Every Code Machine runs the same on any device.
::
::
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Codchi's goal is to minimize the amount of thoughts you put into your developmen

Code machines are to Codchi what containers are to Docker. A code machine is comprised of a number of *modules* (usually just one). A module is a plain NixOS Module inside a git repository which defines the development environment of that repository. Since it's just code, it is versioned just as the rest of the repository, which gives Codchi the ability to create a development environment for every commit of that project.

![Codchi architecture diagram](/architecture.png)

After configuration a code machine is built into a NixOS system inside a container. On Windows this is a WSL instance, on Linux a LXD container. The Codchi binary itself runs on the host system in order to provide features like passthrough of graphics and sound or start menu shortcuts for applications inside code machines. Also Codchi provides niceties like store-sharing between machines. In essence Codchi is a cross-platform driver for NixOS systems that takes care of the tedious hardware and system integration, so that you only have to think about the actual programs and services you want to run.

## When should I (not) use Codchi?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

On Windows, Codchi uses the [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl), which is available for free from Microsoft.

::: warning
::alert{type="warning"}
Installing WSL enables Microsoft's Hyper-V Hypervisor, which might cause issues with older virtualisation technologies like VMware. Don't worry, you can [disable or re-enable Hyper-V](https://learn.microsoft.com/en-us/troubleshoot/windows-client/application-management/virtualization-apps-not-work-with-hyper-v) at any time.
:::
::

Make sure that WSL2 is installed and up to date. In a terminal, `wsl.exe
--version` should output something like the following, where WSL-Version
Expand Down Expand Up @@ -94,7 +94,7 @@ nix profile install github:aformatik/codchi

### Shell Completions

When installed via Nix, shell completions should automatically work inside bash, zsh and fish. There are also [completions](../usage/completion.md) available for the following shells which must be installed manually by the user:
When installed via Nix, shell completions should automatically work inside bash, zsh and fish. There are also [completions](../2.usage/completion.md) available for the following shells which must be installed manually by the user:

- carapace
- elvish
Expand Down Expand Up @@ -181,6 +181,6 @@ In your NixOS configuration:

## MacOS

::: details
::alert{type="info"}
Currently not implemented. Possible Drivers are <https://orbstack.dev/> (proprietary) and <https://lima-vm.io/> (open source, limited support for the newer faster virtualisation on Macs)
:::
::
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Open a terminal and create the machine with a `MACHINE_NAME` of your choice. If
codchi init MACHINE_NAME https://github.com/link/to/repo
```

::: tip
::alert{type="info"}
If you don't have a repository with a Codchi module, you can try this machine (OpenJDK, Maven and IntelliJ IDEA):
```bash
codchi init MACHINE_NAME https://github.com/aformatik/codchi nixosModules.jvm
```
:::
::

Thats it! After a few minutes your machine should be installed and you can now open a shell inside the machine or directly run a program:
```bash
Expand Down
36 changes: 36 additions & 0 deletions docs/content/1.introduction/3.config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Configuration

Codchi itself can be configured via the system tray icon or by editing:

- **Windows:** `%APPDATA%\codchi\config.toml` (`%APPDATA%` is most likely `C:\Users\NAME\AppData\Roaming`)
- **Linux:** `$XDG_CONFIG_HOME/codchi/config.toml` (`$XDG_CONFIG_HOME` is most likely `~/.config`)

::code-group

```toml [Minimal config.toml (All systems)]
# Just leave it empty to use the defaults. This is sufficient for most users
```

```toml [Complete config.toml (Windows)]
data_dir = 'C:\Users\me\AppData\Local\codchi'

tray.autostart = true

[vcxsrv]
enable = true
tray_icon = false
```

```toml [Complete config.toml (Linux)]
data_dir = "/home/me/.local/share/codchi"
tray.autostart = true
```

::

| **Key** | **Type** | **Default** | **Description** |
| ------ | ---- | ------- | ------------- |
| `data_dir` | `string` | `%LOCALAPPDATA%\codchi`, `$XDG_DATA_HOME/codchi` | The path where codchi stores data files from code machines |
| `tray.autostart` | `bool` | `true` | Whether to automatically start the Codchi system tray icon |
| `vcxsrv.enable` (Windows only) | `bool` | `true` | Whether to use [VcXsrv](https://github.com/marchaesen/vcxsrv), a X-Server for Windows, instead of Windows' own RDP solution. VcXsrv mostly has a better user experience and better performance but still has some bugs |
| `vcxsrv.tray_icon` (Windows only) | `bool` | `false` | Whether to show VcXsrv's system tray icon
File renamed without changes.
2 changes: 2 additions & 0 deletions docs/content/1.introduction/_dir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
icon: ph:star-duotone
navigation.redirect: /introduction/getting-started
2 changes: 2 additions & 0 deletions docs/content/2.usage/_dir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: 'Command Reference'
icon: mdi:bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Every code machine is a NixOS system consisting of a range of Codchi modules, each corresponding to a NixOS module. So, configuring a code machine is the same as configuring a NixOS system, without you having to worry about hardware configuration.

A NixOS module is written in Nix's own configuration language with the same name. Nix (the language) can be described as "JSON with functions". To write your first Codchi module,
- read [the tutorial](./start.md)
- read [the tutorial](./1.start.md)
- and look at [the examples](https://github.com/aformatik/codchi/tree/master/nix/examples)
- and the language specific chapters in this section.

Expand All @@ -16,9 +16,9 @@ You can also as questions by
- [creating an GitHub issue](https://github.com/aformatik/codchi/issues/new/choose)
- or in the [Nix Discourse](https://discourse.nixos.org/).

During module development, you most likely don't want to push after every config change. To switch your code machine to your local working copy, see chapter [Local Configuration](../start/usage.md#local-configuration).
During module development, you most likely don't want to push after every config change. To switch your code machine to your local working copy, see chapter [Local Configuration](../2.usage/module/module.html#local-configuration).

## Additional Resources

- Search more than 10 000 NixOS options and 100 000 Nix packages available in Codchi: <https://search.nixos.org>
- [Codchi-specific NixOS options](../options.md)
- [Codchi-specific NixOS options](./99.Codchi specific NixOS Options.md)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ Sometimes there is the need for user-specific variables and / or secrets, which

With Codchi these secrets can be *described* via NixOS options. Lateron, when a user installs a machine with this config, Codchi will prompt him to enter the specific secret value. The value is then made available via environment variables inside the machine.

::: warning

::alert{type="warning"}

**Warning**

<br>
<br>

Codchi stores secret values in plain text on the host. Also they are available via plain environment variables inside a code machine. Therefore they should not be used for super sensitive secrets.

:::
::

Here's an example:

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `flake.nix`, devenv.sh, flox
# flake.nix, devenv.sh, flox

## `flake.nix`
## flake.nix

Because a code machine is just a NixOS machine with flakes enabled, even a empty code machine supports flakes per default (try `codchi init <NAME>` without args!). But you can use the configuration to provide tools which the flake doesn't provide:

Expand All @@ -21,7 +21,7 @@ Because a code machine is just a NixOS machine with flakes enabled, even a empty

## devenv.sh, flox

As described in [the intro](../start/intro.md#when-should-i-not-use-codchi), Codchi doesn't try to do the job of tools like [devenv.sh](https://devenv.sh/) or [flox](https://flox.dev/). Instead, both can be used together, each for their respective purpose: Codchi provides a consistent environment across Windows and Linux and devenv.sh or flox provide the development environment itself.
As described in [the intro](../1.introduction/0.what-is-codchi.md#when-should-i-not-use-codchi), Codchi doesn't try to do the job of tools like [devenv.sh](https://devenv.sh/) or [flox](https://flox.dev/). Instead, both can be used together, each for their respective purpose: Codchi provides a consistent environment across Windows and Linux and devenv.sh or flox provide the development environment itself.

```nix
{ pkgs, ... }: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ See <https://wiki.nixos.org/wiki/Vscode> for more info.

## Jetbrains IDEs

See chapter [JVM](./examples/jvm.md#general-java--kotlin) on how to setup JDKs for Java IDEs like IntelliJ.
See chapter [JVM](./6.environments/jvm.md#general-java--kotlin) on how to setup JDKs for Java IDEs like IntelliJ.

All Jetbrains IDEs are available under `pkgs.jetbrains.<IDE>`. See the [NixOS Search](https://search.nixos.org/packages?channel=unstable&from=0&size=51&sort=relevance&type=packages&query=jetbrains) for a list of available IDEs.

Expand Down
2 changes: 2 additions & 0 deletions docs/content/3.config/6.environments/_dir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: 'Environments'
icon: ph:package-duotone
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions docs/content/3.config/_dir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: 'Module Configuration'
icon: ph:gear-duotone
2 changes: 2 additions & 0 deletions docs/content/4.contrib/_dir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: 'Contributing'
icon: ph:github-logo-duotone
Loading

0 comments on commit b01244a

Please sign in to comment.